Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: function: f_eem: socket buffer may be NULL

In eth_start_xmit, the socket buffer may be NULL. So, add NULL pointer
check at .wrap API.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Peter Chen and committed by
Felipe Balbi
70237dc8 3295235f

+7 -3
+7 -3
drivers/usb/gadget/function/f_eem.c
··· 341 341 { 342 342 struct sk_buff *skb2 = NULL; 343 343 struct usb_ep *in = port->in_ep; 344 - int padlen = 0; 344 + int headroom, tailroom, padlen = 0; 345 345 u16 len = skb->len; 346 346 347 - int headroom = skb_headroom(skb); 348 - int tailroom = skb_tailroom(skb); 347 + if (!skb) 348 + return NULL; 349 + 350 + len = skb->len; 351 + headroom = skb_headroom(skb); 352 + tailroom = skb_tailroom(skb); 349 353 350 354 /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0, 351 355 * stick two bytes of zero-length EEM packet on the end.