From: Sean Young <sean@mess.org>
To: Nil Yi <teroincn@163.com>
Cc: crope@iki.fi, linux-media@vger.kernel.org
Subject: Re: [PATCH] media: usb: dvb-usb-v2: clean the freed pointer and counter
Date: Tue, 17 Aug 2021 12:01:09 +0100 [thread overview]
Message-ID: <20210817110109.GA18933@gofer.mess.org> (raw)
In-Reply-To: <20210815100109.GA70768@nilus-desk>
On Sun, Aug 15, 2021 at 06:01:09PM +0800, Nil Yi wrote:
> After urb was freed, the pointer and counter need to be
> cleaned.
Ideally the commit message will say why this change needs happen, i.e.
what code path might lead to something bad happening.
I'm re-reading the code and I'm having a hard time figuring out what
that code path is, i.e. why this patch is needed.
Also "cleaned" isn't common terminology as far I know. Better to avoid
that.
Thanks
Sean
>
> 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
>
prev parent reply other threads:[~2021-08-17 11:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210817110109.GA18933@gofer.mess.org \
--to=sean@mess.org \
--cc=crope@iki.fi \
--cc=linux-media@vger.kernel.org \
--cc=teroincn@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox