Skip to contentSkip to conversation

usbtv: correctly handling failed allocation

PATCH New Insu Yun 1 participant 1 message Dec 29, 2015 Media (V4L/DVB)

lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 usbtv: correctly handling failed allocation

Since kzalloc can be failed,
if not properly handled, NULL dereference could be happened.

---
 drivers/media/usb/usbtv/usbtv-video.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/usb/usbtv/usbtv-video.c +4 -0
index e645c9d..92d8d7a 100644
@@ -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;
Signature · 1 line
1.9.1