]> git.baikalelectronics.ru Git - kernel.git/commit
USB CDC NCM: Don't deref NULL in cdc_ncm_rx_fixup() and don't use uninitialized variable.
authorJesper Juhl <jj@chaosbits.net>
Thu, 13 Jan 2011 11:40:11 +0000 (11:40 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Jan 2011 05:48:26 +0000 (21:48 -0800)
commitcaa9e9a8f6e1ac503e0951946c347f5f7a897514
tree0557144779a2ad51093110dce0cdc163592e15fb
parente22ca7446b4060f12cc57bbef38e27ea4aa38b3d
USB CDC NCM: Don't deref NULL in cdc_ncm_rx_fixup() and don't use uninitialized variable.

skb_clone() dynamically allocates memory and may fail. If it does it
returns NULL. This means we'll dereference a NULL pointer in
drivers/net/usb/cdc_ncm.c::cdc_ncm_rx_fixup().
As far as I can tell, the proper way to deal with this is simply to goto
the error label.

Furthermore gcc complains that 'skb' may be used uninitialized:
  drivers/net/usb/cdc_ncm.c: In function ‘cdc_ncm_rx_fixup’:
  drivers/net/usb/cdc_ncm.c:922:18: warning: ‘skb’ may be used uninitialized in this function
and I believe it is right. On the line where we
  pr_debug("invalid frame detected (ignored)" ...
we are using the local variable 'skb' but nothing has ever been assigned
to that variable yet. I believe the correct fix for that is to use
'skb_in' instead.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_ncm.c