From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB9D9C4338F for ; Tue, 17 Aug 2021 11:01:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6AA260C40 for ; Tue, 17 Aug 2021 11:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236253AbhHQLBo (ORCPT ); Tue, 17 Aug 2021 07:01:44 -0400 Received: from gofer.mess.org ([88.97.38.141]:34459 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236413AbhHQLBo (ORCPT ); Tue, 17 Aug 2021 07:01:44 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id EEB74C6459; Tue, 17 Aug 2021 12:01:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1629198069; bh=3Hf2kjmrZS7y5m+g+HH4Wijwu9LoVfWTnc54wguFOwo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nxsjQy5wvPaeVVrzE1FwK1kB/GD1ql48uST7OIIHHX6VTTwlmhKXZPyq1gWuu6Led Yux02baUm3Ub7OvqcGebCwxatsUcBQlptj8GWsY4ffvA6iEfU0dx4oGc5QChhV8HcO X0VjxOS8xHzv16j3q7rPJt+RYWqjvHuOSq4BPUOHH87KTrdMqTz0Wb/KhOx4SED3zp cIfYwNwNxQrm3cbY6P+LwpSv4OrNZSWITAS8ciKTW4i1y3QSjRvvzlVf0/HVlAORKU PJG5tCTWLqBs78U/Ke7D2KdhQDaP5X7GqRB4432LywrU9DUtuFlAr0OeFJn31N6KjY rtV66pMoWR4fg== Date: Tue, 17 Aug 2021 12:01:09 +0100 From: Sean Young To: Nil Yi Cc: crope@iki.fi, linux-media@vger.kernel.org Subject: Re: [PATCH] media: usb: dvb-usb-v2: clean the freed pointer and counter Message-ID: <20210817110109.GA18933@gofer.mess.org> References: <20210815100109.GA70768@nilus-desk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210815100109.GA70768@nilus-desk> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 > --- > 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 >