From: Vince Hsu <vinceh@nvidia.com>
To: Ilia Mirkin <imirkin@alum.mit.edu>,
Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "dri-devel@lists.freedesktop.org" <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v1] drm/nouveau/clk: avoid potential null-dereference
Date: Thu, 8 Jan 2015 12:32:06 +0800 [thread overview]
Message-ID: <54AE0846.4000503@nvidia.com> (raw)
In-Reply-To: <CAKb7Uvgxna9CcoNryUyeN0cw-y1n8Q1vfzRdsWK4+0P1qXoT3Q@mail.gmail.com>
On 01/08/2015 10:45 AM, Ilia Mirkin wrote:
> On Wed, Jan 7, 2015 at 5:29 PM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
>> We have to check pointer before usage.
>>
>> Reported-by: Andrey Karpov <karpov@viva64.com>
>> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>> ---
>> drivers/gpu/drm/nouveau/core/subdev/clock/base.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
>> index e51b72d..2e84436 100644
>> --- a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
>> +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c
>> @@ -322,7 +322,6 @@ nouveau_pstate_new(struct nouveau_clock *clk, int idx)
>> return 0;
>>
>> pstate = kzalloc(sizeof(*pstate), GFP_KERNEL);
>> - cstate = &pstate->base;
> What's wrong with this line? If pstate == NULL, &pstate->base == NULL
> as well and we return.
If pstate == NULL (kzalloc returned NULL), pstate->base triggers a null
pointer
deference error?
Thanks,
Vince
>
>> if (!pstate)
>> return -ENOMEM;
>>
>> @@ -330,6 +329,9 @@ nouveau_pstate_new(struct nouveau_clock *clk, int idx)
>>
>> pstate->pstate = perfE.pstate;
>> pstate->fanspeed = perfE.fanspeed;
>> +
>> + cstate = &pstate->base;
>> +
>> cstate->voltage = perfE.voltage;
>> cstate->domain[nv_clk_src_core] = perfE.core;
>> cstate->domain[nv_clk_src_shader] = perfE.shader;
>> --
>> 1.8.3.101.g727a46b
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-01-08 4:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 22:29 [PATCH v1] drm/nouveau/clk: avoid potential null-dereference Andy Shevchenko
2015-01-08 2:45 ` Ilia Mirkin
2015-01-08 4:32 ` Vince Hsu [this message]
2015-01-08 4:57 ` Ilia Mirkin
2015-01-08 5:40 ` Vince Hsu
2015-01-08 5:52 ` Ilia Mirkin
2015-01-08 6:02 ` Vince Hsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54AE0846.4000503@nvidia.com \
--to=vinceh@nvidia.com \
--cc=andy.shevchenko@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=imirkin@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.