Subject: Re: [PATCH] usbnet: dereference after null check in usbnet_start_xmit() and __usbnet_read_cmd()

From: Bjørn Mork <[email-masked]>
Date: Thu, 20 Aug 2015 09:29:05 +0200

Vivek Kumar Bhagat <[email-masked]> writes:

> Dear Bjorn,
>
>>>This is wrong.  There are usbnet minidrivers depending on info->tx_fixup
>>> being called with a NULL skb.
> Also, if dev_hard_start_xmit() ensures that skb can not be NULL in usbnet_start_xmit()
> then we should remove below check.
>     if (skb)      <--- This check is confusing which says skb can be NULL.
>                 skb_tx_timestamp(skb); 

No, that test is there because of the ugly hack in cdc_ncm.  It doesn't
go through dev_hard_start_xmit(), but calls usbnet_start_xmit() directly
with a NULL skb as a signal to itself.  Yes, I told you it was ugly ;)

I do agree that it would be nice to make this go away.  But until that
happens usbnet_start_xmit() has to deal with NULL skbs, forwarding them
to the tx_fixup hook.

Bjørn