Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1523763 > unrolled thread

[PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null

Started byColin King <colin.king@canonical.com>
First post2016-11-16 20:20 +0100
Last post2016-11-21 12:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null Colin King <colin.king@canonical.com> - 2016-11-16 20:20 +0100
    Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before  checking it is null Matthias Brugger <mbrugger@suse.com> - 2016-11-18 11:00 +0100
    Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before  checking it is null andrew-ct chen <andrew-ct.chen@mediatek.com> - 2016-11-21 12:20 +0100

#1523763 — [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null

FromColin King <colin.king@canonical.com>
Date2016-11-16 20:20 +0100
Subject[PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null
Message-ID<sEdUt-70N-11@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

pdev is dereferenced using platform_get_drvdata before a check to
see if it is null, hence there could be a potential null pointer
dereference issue. Instead, first check if pdev is null and only then
deference pdev when initializing vpu.

Found with static analysis by CoverityScan, CID 1357797

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
index c9bf58c..41f31b2 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -523,9 +523,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
 
 int vpu_load_firmware(struct platform_device *pdev)
 {
-	struct mtk_vpu *vpu = platform_get_drvdata(pdev);
+	struct mtk_vpu *vpu;
 	struct device *dev = &pdev->dev;
-	struct vpu_run *run = &vpu->run;
+	struct vpu_run *run;
 	const struct firmware *vpu_fw = NULL;
 	int ret;
 
@@ -533,6 +533,8 @@ int vpu_load_firmware(struct platform_device *pdev)
 		dev_err(dev, "VPU platform device is invalid\n");
 		return -EINVAL;
 	}
+	vpu = platform_get_drvdata(pdev);
+	run = &vpu->run;
 
 	mutex_lock(&vpu->vpu_mutex);
 	if (vpu->fw_loaded) {
-- 
2.10.2

[toc] | [next] | [standalone]


#1525137 — Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null

FromMatthias Brugger <mbrugger@suse.com>
Date2016-11-18 11:00 +0100
SubjectRe: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null
Message-ID<sEO7D-5nR-1@gated-at.bofh.it>
In reply to#1523763

On 16/11/16 20:16, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> pdev is dereferenced using platform_get_drvdata before a check to
> see if it is null, hence there could be a potential null pointer
> dereference issue. Instead, first check if pdev is null and only then
> deference pdev when initializing vpu.
>
> Found with static analysis by CoverityScan, CID 1357797
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Reviewed-by: Matthias Brugger <mbrugger@suse.com>

>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> index c9bf58c..41f31b2 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
>
>  int vpu_load_firmware(struct platform_device *pdev)
>  {
> -	struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> +	struct mtk_vpu *vpu;
>  	struct device *dev = &pdev->dev;
> -	struct vpu_run *run = &vpu->run;
> +	struct vpu_run *run;
>  	const struct firmware *vpu_fw = NULL;
>  	int ret;
>
> @@ -533,6 +533,8 @@ int vpu_load_firmware(struct platform_device *pdev)
>  		dev_err(dev, "VPU platform device is invalid\n");
>  		return -EINVAL;
>  	}
> +	vpu = platform_get_drvdata(pdev);
> +	run = &vpu->run;
>
>  	mutex_lock(&vpu->vpu_mutex);
>  	if (vpu->fw_loaded) {
>

[toc] | [prev] | [next] | [standalone]


#1526579 — Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null

Fromandrew-ct chen <andrew-ct.chen@mediatek.com>
Date2016-11-21 12:20 +0100
SubjectRe: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null
Message-ID<sFUNH-sG-3@gated-at.bofh.it>
In reply to#1523763
On Wed, 2016-11-16 at 19:16 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> pdev is dereferenced using platform_get_drvdata before a check to
> see if it is null, hence there could be a potential null pointer
> dereference issue. Instead, first check if pdev is null and only then
> deference pdev when initializing vpu.
> 
> Found with static analysis by CoverityScan, CID 1357797
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Reviewed-by: Andrew-CT Chen <andrew-ct.chen@mediatek.com>

>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> index c9bf58c..41f31b2 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
>  
>  int vpu_load_firmware(struct platform_device *pdev)
>  {
> -	struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> +	struct mtk_vpu *vpu;
>  	struct device *dev = &pdev->dev;
> -	struct vpu_run *run = &vpu->run;
> +	struct vpu_run *run;
>  	const struct firmware *vpu_fw = NULL;
>  	int ret;
>  
> @@ -533,6 +533,8 @@ int vpu_load_firmware(struct platform_device *pdev)
>  		dev_err(dev, "VPU platform device is invalid\n");
>  		return -EINVAL;
>  	}
> +	vpu = platform_get_drvdata(pdev);
> +	run = &vpu->run;
>  
>  	mutex_lock(&vpu->vpu_mutex);
>  	if (vpu->fw_loaded) {

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web