2013-09-11 14:09:06

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH] drm/msm: fix potential NULL pointer dereference

From: Wei Yongjun <[email protected]>

The dereference to 'pdata' should be moved below the NULL test.

Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/gpu/drm/msm/msm_gpu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index e1e1ec9..6b50e6b 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -29,13 +29,14 @@
static void bs_init(struct msm_gpu *gpu, struct platform_device *pdev)
{
struct drm_device *dev = gpu->dev;
- struct kgsl_device_platform_data *pdata = pdev->dev.platform_data;
+ struct kgsl_device_platform_data *pdata;

if (!pdev) {
dev_err(dev->dev, "could not find dtv pdata\n");
return;
}

+ pdata = pdev->dev.platform_data;
if (pdata->bus_scale_table) {
gpu->bsc = msm_bus_scale_register_client(pdata->bus_scale_table);
DBG("bus scale client: %08x", gpu->bsc);


2013-09-11 19:03:32

by Rob Clark

[permalink] [raw]
Subject: Re: [PATCH] drm/msm: fix potential NULL pointer dereference

On Wed, Sep 11, 2013 at 10:09 AM, Wei Yongjun <[email protected]> wrote:
> From: Wei Yongjun <[email protected]>
>
> The dereference to 'pdata' should be moved below the NULL test.
>
> Signed-off-by: Wei Yongjun <[email protected]>

Acked-by: Rob Clark <[email protected]>

> ---
> drivers/gpu/drm/msm/msm_gpu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index e1e1ec9..6b50e6b 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -29,13 +29,14 @@
> static void bs_init(struct msm_gpu *gpu, struct platform_device *pdev)
> {
> struct drm_device *dev = gpu->dev;
> - struct kgsl_device_platform_data *pdata = pdev->dev.platform_data;
> + struct kgsl_device_platform_data *pdata;
>
> if (!pdev) {
> dev_err(dev->dev, "could not find dtv pdata\n");
> return;
> }
>
> + pdata = pdev->dev.platform_data;
> if (pdata->bus_scale_table) {
> gpu->bsc = msm_bus_scale_register_client(pdata->bus_scale_table);
> DBG("bus scale client: %08x", gpu->bsc);
>