Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1299149 > unrolled thread

[PATCH] usbtv: correctly handling failed allocation

Started byInsu Yun <wuninsu@gmail.com>
First post2015-12-29 22:50 +0100
Last post2015-12-29 22:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] usbtv: correctly handling failed allocation Insu Yun <wuninsu@gmail.com> - 2015-12-29 22:50 +0100

#1299149 — [PATCH] usbtv: correctly handling failed allocation

FromInsu Yun <wuninsu@gmail.com>
Date2015-12-29 22:50 +0100
Subject[PATCH] usbtv: correctly handling failed allocation
Message-ID<qLajw-60m-7@gated-at.bofh.it>
Since kzalloc can be failed, 
if not properly handled, NULL dereference could be happened.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/media/usb/usbtv/usbtv-video.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index e645c9d..92d8d7a 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -389,6 +389,10 @@ static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv)
 	ip->transfer_flags = URB_ISO_ASAP;
 	ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS,
 						GFP_KERNEL);
+	if (!ip->transfer_buffer) {
+		usb_free_urb(ip);
+		return NULL;
+	}
 	ip->complete = usbtv_iso_cb;
 	ip->number_of_packets = USBTV_ISOC_PACKETS;
 	ip->transfer_buffer_length = size * USBTV_ISOC_PACKETS;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web