linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: usb: dvb-usb-v2: clean the freed pointer and counter
@ 2021-08-15 10:01 Nil Yi
  2021-08-17 11:01 ` Sean Young
  0 siblings, 1 reply; 2+ messages in thread
From: Nil Yi @ 2021-08-15 10:01 UTC (permalink / raw)
  To: crope, linux-media

After urb was freed, the pointer and counter need to be
cleaned.

Signed-off-by: Nil Yi <teroincn@163.com>
---
 drivers/media/usb/dvb-usb-v2/usb_urb.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/usb_urb.c b/drivers/media/usb/dvb-usb-v2/usb_urb.c
index 2ad2ddeaf..08ba2d138 100644
--- a/drivers/media/usb/dvb-usb-v2/usb_urb.c
+++ b/drivers/media/usb/dvb-usb-v2/usb_urb.c
@@ -143,8 +143,11 @@ static int usb_urb_alloc_bulk_urbs(struct usb_data_stream *stream)
 		stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
 		if (!stream->urb_list[i]) {
 			dev_dbg(&stream->udev->dev, "%s: failed\n", __func__);
-			for (j = 0; j < i; j++)
+			for (j = 0; j < i; j++) {
 				usb_free_urb(stream->urb_list[j]);
+				stream->urb_list[j] = NULL;
+			}
+			stream->urbs_initialized = 0;
 			return -ENOMEM;
 		}
 		usb_fill_bulk_urb(stream->urb_list[i],
@@ -173,8 +176,11 @@ static int usb_urb_alloc_isoc_urbs(struct usb_data_stream *stream)
 				stream->props.u.isoc.framesperurb, GFP_ATOMIC);
 		if (!stream->urb_list[i]) {
 			dev_dbg(&stream->udev->dev, "%s: failed\n", __func__);
-			for (j = 0; j < i; j++)
+			for (j = 0; j < i; j++) {
 				usb_free_urb(stream->urb_list[j]);
+				stream->urb_list[j] = NULL;
+			}
+			stream->urbs_initialized = 0;
 			return -ENOMEM;
 		}
 
-- 
2.17.1



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

end of thread, other threads:[~2021-08-17 11:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-15 10:01 [PATCH] media: usb: dvb-usb-v2: clean the freed pointer and counter Nil Yi
2021-08-17 11:01 ` Sean Young

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