linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev
@ 2016-09-07 17:10 Colin King
  2016-09-08  5:21 ` Tiffany Lin
  2016-09-09  1:25 ` andrew-ct chen
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-09-07 17:10 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Matthias Brugger, Hans Verkuil,
	Wei Yongjun, Tiffany Lin, Andrew-CT Chen, linux-media,
	linux-arm-kernel, linux-mediatek
  Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

pdev is being null checked, however, prior to that it is being
dereferenced by platform_get_drvdata.  Move the assignments of
vpu and run to after the pdev null check to avoid a potential
null pointer dereference.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.c | 7 +++++--
 1 file changed, 5 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..43907a3 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;
 
@@ -534,6 +534,9 @@ int vpu_load_firmware(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	vpu = platform_get_drvdata(pdev);
+	run = &vpu->run;
+
 	mutex_lock(&vpu->vpu_mutex);
 	if (vpu->fw_loaded) {
 		mutex_unlock(&vpu->vpu_mutex);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev
  2016-09-07 17:10 [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev Colin King
@ 2016-09-08  5:21 ` Tiffany Lin
  2016-09-09  1:25 ` andrew-ct chen
  1 sibling, 0 replies; 3+ messages in thread
From: Tiffany Lin @ 2016-09-08  5:21 UTC (permalink / raw)
  To: Colin King
  Cc: Mauro Carvalho Chehab, Matthias Brugger, Hans Verkuil,
	Wei Yongjun, Andrew-CT Chen, linux-media, linux-arm-kernel,
	linux-mediatek, linux-kernel

On Wed, 2016-09-07 at 18:10 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> pdev is being null checked, however, prior to that it is being
> dereferenced by platform_get_drvdata.  Move the assignments of
> vpu and run to after the pdev null check to avoid a potential
> null pointer dereference.
> 

Reviewed-by:Tiffany Lin <tiffany.lin@mediatek.com>

> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 7 +++++--
>  1 file changed, 5 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..43907a3 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;
>  
> @@ -534,6 +534,9 @@ int vpu_load_firmware(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> +	vpu = platform_get_drvdata(pdev);
> +	run = &vpu->run;
> +
>  	mutex_lock(&vpu->vpu_mutex);
>  	if (vpu->fw_loaded) {
>  		mutex_unlock(&vpu->vpu_mutex);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev
  2016-09-07 17:10 [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev Colin King
  2016-09-08  5:21 ` Tiffany Lin
@ 2016-09-09  1:25 ` andrew-ct chen
  1 sibling, 0 replies; 3+ messages in thread
From: andrew-ct chen @ 2016-09-09  1:25 UTC (permalink / raw)
  To: Colin King
  Cc: Mauro Carvalho Chehab, Matthias Brugger, Hans Verkuil,
	Wei Yongjun, Tiffany Lin, linux-media, linux-arm-kernel,
	linux-mediatek, linux-kernel

On Wed, 2016-09-07 at 18:10 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> pdev is being null checked, however, prior to that it is being
> dereferenced by platform_get_drvdata.  Move the assignments of
> vpu and run to after the pdev null check to avoid a potential
> null pointer dereference.
> 

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

> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 7 +++++--
>  1 file changed, 5 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..43907a3 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;
>  
> @@ -534,6 +534,9 @@ int vpu_load_firmware(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> +	vpu = platform_get_drvdata(pdev);
> +	run = &vpu->run;
> +
>  	mutex_lock(&vpu->vpu_mutex);
>  	if (vpu->fw_loaded) {
>  		mutex_unlock(&vpu->vpu_mutex);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-09  1:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07 17:10 [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev Colin King
2016-09-08  5:21 ` Tiffany Lin
2016-09-09  1:25 ` andrew-ct chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).