All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] usb: check udev before dereferencing
Date: Sat, 12 Nov 2016 19:17:23 +0100	[thread overview]
Message-ID: <a6fef258-c3ea-f06f-2f14-550ede9d8d3e@denx.de> (raw)
In-Reply-To: <20161112191028.6acc5536@crub>

On 11/12/2016 07:10 PM, Anatolij Gustschin wrote:
> On Sat, 12 Nov 2016 10:36:42 +0100
> Marek Vasut marex at denx.de wrote:
> ...
>>>  		udev = dev_get_parent_priv(child);
>>> +		if (!udev)
>>> +			continue;  
>>
>> I don't quite understand the problem from the patch description, but
>> shouldn't all the return values from dev_get_parent_priv() be checked
>> this way , not just these two ?
> 
> The problem is that when dereferencing NULL udev we later access
> some random address (e.g. when accessing dev->dev->parent in
> usb_show_tree_graph()). dev->dev pointer is random DRAM data there,
> when dereferencing it, data abort happens when random address
> is outside of valid address range.

I mean, I understand that udev can be NULL and we don't check it. But is
udev == NULL an expected possibility ? And if so, when does such thing
happen ?

> Probably we should check elsewhere, at least where it might
> return NULL.

OK

>>
>> Why does dev_get_parent_priv() return NULL here ?
> 
> it returns NULL because the dev->parent_priv is not allocated for
> usb_mass_storage.lun0 device. I do not know the reason why.

That's probably what needs to be fixed , no ?

Also, we should most likely check all the return values of
dev_get_parent_priv() in cmd/usb.c, not just these two.

-- 
Best regards,
Marek Vasut

  reply	other threads:[~2016-11-12 18:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-12  9:02 [U-Boot] [PATCH] usb: check udev before dereferencing Anatolij Gustschin
2016-11-12  9:36 ` Marek Vasut
2016-11-12 18:10   ` Anatolij Gustschin
2016-11-12 18:17     ` Marek Vasut [this message]
2016-11-14 20:44       ` Simon Glass

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=a6fef258-c3ea-f06f-2f14-550ede9d8d3e@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.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 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.