Hello Dan,

Thanks for this check.

W dniu 31.10.2014 o 14:06, Dan Carpenter pisze:
Hello Andrzej Pietrasiewicz,

This is a semi-automatic email about new static checker warnings.


<snip>


drivers/usb/gadget/function/u_uac1.c
    210 
    211         opts = container_of(card->func.fi, struct f_uac1_opts, 
func_inst);
                                     ^^^^^^^^^^^^^
New dereference.

    212         fn_play = opts->fn_play;
                           ^^^^^^^^^^^^^
Technically, I think the container_of() just does pointer math and the
actual dereference is here.  I'm not sure, either way it's dereferenced.

    213         fn_cap = opts->fn_cap;
    214         fn_cntl = opts->fn_cntl;
    215 
    216         if (!card)
                     ^^^^^
Existing code assumes card can be NULL.


gaudio_open_snd_dev() is called from gaudio_setup(), which is called
when this function instance is first bound and the card parameter
is propagated from f_audio_bind().

In f_audio_bind() the audio local variable is dereferenced to get
the "card". audio itself is a container_of struct usb_function
and also contains struct gaudio (as a regular member, not a pointer).
So if the said usb_function is non-NULL, its container's "card" member
is non-NULL either.

The struct usb_function is passed from composite.c:usb_add_function()
where it is assumed to be non-NULL. This means that the check in line 216
is not needed.

Actually in the circulation there has been your patch:

5d5515f389a0db9da5ee85481a5939508aa31dec
usb: gadget: f_uac1: remove an unneeded NULL check

which implements exactly what I described above.

AP

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to