linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: add error handling for skb_realloc_headroom
@ 2018-06-12  4:41 Zhouyang Jia
  2018-06-19  9:47 ` Felipe Balbi
  2018-06-19 12:23 ` [PATCH v2] " Zhouyang Jia
  0 siblings, 2 replies; 4+ messages in thread
From: Zhouyang Jia @ 2018-06-12  4:41 UTC (permalink / raw)
  Cc: Zhouyang Jia, Felipe Balbi, Greg Kroah-Hartman, Bhumika Goyal,
	Johan Hovold, Andrew Gabbasov, David Lechner, linux-usb,
	linux-kernel

When skb_realloc_headroom fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling skb_realloc_headroom.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/usb/gadget/function/f_rndis.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index d48df36..17c164b 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -374,6 +374,9 @@ static struct sk_buff *rndis_add_header(struct gether *port,
 		return NULL;
 
 	skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type));
+	if (!skb2)
+		return NULL;
+
 	rndis_add_hdr(skb2);
 
 	dev_kfree_skb(skb);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-29  6:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-12  4:41 [PATCH] usb: gadget: add error handling for skb_realloc_headroom Zhouyang Jia
2018-06-19  9:47 ` Felipe Balbi
2018-06-19 12:23 ` [PATCH v2] " Zhouyang Jia
2018-06-29  6:36   ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).