2014-04-15 01:56:56

by Daeseok Youn

[permalink] [raw]
Subject: [PATCH] drm/nouveau/clk: fix possible NULL pointer dereference


It need to be checking NULL before dereferencing.

Signed-off-by: Daeseok Youn <[email protected]>
---
drivers/gpu/drm/nouveau/core/subdev/clock/base.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
index dd62bae..a586d030 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
@@ -290,9 +290,9 @@ nouveau_pstate_new(struct nouveau_clock *clk, int idx)
return 0;

pstate = kzalloc(sizeof(*pstate), GFP_KERNEL);
- cstate = &pstate->base;
if (!pstate)
return -ENOMEM;
+ cstate = &pstate->base;

INIT_LIST_HEAD(&pstate->list);

--
1.7.4.4


2014-04-15 07:00:42

by Ben Skeggs

[permalink] [raw]
Subject: Re: [PATCH] drm/nouveau/clk: fix possible NULL pointer dereference

----- Original Message -----
> From: "Daeseok Youn" <[email protected]>
> To: [email protected]
> Cc: [email protected], [email protected], [email protected]
> Sent: Tuesday, 15 April, 2014 11:56:49 AM
> Subject: [PATCH] drm/nouveau/clk: fix possible NULL pointer dereference
>
>
> It need to be checking NULL before dereferencing.
There's no dereference here. It's an address calculation only.

>
> Signed-off-by: Daeseok Youn <[email protected]>
> ---
> drivers/gpu/drm/nouveau/core/subdev/clock/base.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
> b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
> index dd62bae..a586d030 100644
> --- a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
> +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
> @@ -290,9 +290,9 @@ nouveau_pstate_new(struct nouveau_clock *clk, int idx)
> return 0;
>
> pstate = kzalloc(sizeof(*pstate), GFP_KERNEL);
> - cstate = &pstate->base;
> if (!pstate)
> return -ENOMEM;
> + cstate = &pstate->base;
>
> INIT_LIST_HEAD(&pstate->list);
>
> --
> 1.7.4.4
>
>
>

2014-04-15 09:15:24

by Daeseok Youn

[permalink] [raw]
Subject: Re: [PATCH] drm/nouveau/clk: fix possible NULL pointer dereference

2014-04-15 16:00 GMT+09:00 Ben Skeggs <[email protected]>:
> ----- Original Message -----
>> From: "Daeseok Youn" <[email protected]>
>> To: [email protected]
>> Cc: [email protected], [email protected], [email protected]
>> Sent: Tuesday, 15 April, 2014 11:56:49 AM
>> Subject: [PATCH] drm/nouveau/clk: fix possible NULL pointer dereference
>>
>>
>> It need to be checking NULL before dereferencing.
> There's no dereference here. It's an address calculation only.
Oh.. You're right.
But the address calculation doesn't need when "pstate" is NULL.
Can I re-send this patch after modifying subject and comment of this
patch properly?
Or drop this patch.

Thanks for review.

Regards,
Daeseok Youn.
>
>>
>> Signed-off-by: Daeseok Youn <[email protected]>
>> ---
>> drivers/gpu/drm/nouveau/core/subdev/clock/base.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
>> b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
>> index dd62bae..a586d030 100644
>> --- a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
>> +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
>> @@ -290,9 +290,9 @@ nouveau_pstate_new(struct nouveau_clock *clk, int idx)
>> return 0;
>>
>> pstate = kzalloc(sizeof(*pstate), GFP_KERNEL);
>> - cstate = &pstate->base;
>> if (!pstate)
>> return -ENOMEM;
>> + cstate = &pstate->base;
>>
>> INIT_LIST_HEAD(&pstate->list);
>>
>> --
>> 1.7.4.4
>>
>>
>>