mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH] reset: fix potential null pointer dereference on pointer dev
Date: Fri, 10 May 2019 10:16:47 +0100	[thread overview]
Message-ID: <e70ed8dd-3493-d3a0-c964-459b102af3f6@canonical.com> (raw)
In-Reply-To: <1557479671.7859.2.camel@pengutronix.de>

On 10/05/2019 10:14, Philipp Zabel wrote:
> Hi Colin,
> 
> [added Bartosz to Cc:]
> 
> On Thu, 2019-05-09 at 17:00 +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Pointer dev is being dereferenced when passed to the inlined
>> functon dev_name, however, dev is later being null checked.
>> Thus there is a potential null pointer dereference on a null
>> dev. Fix this by performing the null check on dev before
>> dereferencing it.
>>
>> Addresses-Coverity: ("Dereference before null check")
>> Fixes: 6691dffab0ab ("reset: add support for non-DT systems")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/reset/core.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
>> index 81ea77cba123..83f1a1d5ee67 100644
>> --- a/drivers/reset/core.c
>> +++ b/drivers/reset/core.c
>> @@ -691,12 +691,13 @@ __reset_control_get_from_lookup(struct device *dev, const char *con_id,
>>  {
>>  	const struct reset_control_lookup *lookup;
>>  	struct reset_controller_dev *rcdev;
>> -	const char *dev_id = dev_name(dev);
>> +	const char *dev_id;
>>  	struct reset_control *rstc = NULL;
>>  
>>  	if (!dev)
>>  		return ERR_PTR(-EINVAL);
> 
> Thank you for the patch. I think this check should be removed instead,
> though, as __reset_control_get_from_lookup is only ever called from
> __reset_control_get, right after checking dev->of_node. So dev can not
> be NULL here.

Good point, I totally overlooked that. I'll send a V2 shortly.

> 
> regards
> Philipp
> 


      reply	other threads:[~2019-05-10  9:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09 16:00 Colin King
2019-05-10  9:14 ` Philipp Zabel
2019-05-10  9:16   ` Colin Ian King [this message]

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=e70ed8dd-3493-d3a0-c964-459b102af3f6@canonical.com \
    --to=colin.king@canonical.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®