[U-Boot] [PATCH 1/2] net/eth.c: make eth_get_dev_by_name(NULL) safe

Detlev Zundel
2011-07-07T10:24:25Z

Hi Helmut,

> On 07/06/2011 09:38 PM, Mike Frysinger wrote:
>> On Wednesday, July 06, 2011 03:15:08 Helmut Raiger wrote:
>>> On 07/05/2011 05:44 AM, Mike Frysinger wrote:
>>>> On Monday, July 04, 2011 06:29:51 helmut.raiger at hale.at wrote:
>>>>> eth_get_dev_by_name() is not safe to use for devname being NULL
>>>>> as it uses strcmp. This patch makes it return NULL if devname NULL
>>>>> is passed.
>>>> i'm not sure about this. passing NULL is wrong, and the caller should
>>>> catch that shouldnt it ?
>>> So what is your suggestion how to deal with it?
>> in what situation is eth_get_dev_by_name(NULL) being called ? my suggestion
>> would be to fix that call point since it's doing something wrong.
>> -mike
> I couldn't find a situation where this might be the case. But as Luca
> Ceresoli pointed out in his e-mail, somewhere up the thread, that he
> tested for devname being NULL in his miiphy_read and write routines, I
> checked eth_get_dev_by_name() and found that it is vulnerable to passing
> a NULL pointer, hence the fix.
>
> Is there something missing for the patch to be acknowledged?
> It's hanging there quite a while now?

Actually I want to ack your patch. eth_get_dev_by_name is a project
wide utility function and as such should be tolerant to being called
with wrong parameters.

Mike's argument of course also has merit to it, but because of the
"library function" argument, I'd give it less priority. So

Acked-by: Detlev Zundel <dzu@denx.de>

--
We have a live-manual. It's called emacs-devel at gnu.org.
You can stick to just reading it, but you can skip to a specific chapter
by simply sending an email asking for it ;-)
-- Stefan Monnier
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de