diff mbox

[v2] usb: gadget: add error handling for skb_realloc_headroom

Message ID 1529410988-70261-1-git-send-email-jiazhouyang09@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhouyang Jia June 19, 2018, 12:23 p.m. UTC
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(+)

Comments

Felipe Balbi June 29, 2018, 6:36 a.m. UTC | #1
Hi,

linux-usb-owner@vger.kernel.org writes:

> 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>

from linux-usb-owner@vger.kernel.org??
diff mbox

Patch

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);