linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongliang Mu <mudongliangabcd@gmail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Greg KH <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] media: usb: fix memory leak in stk_camera_probe
Date: Thu, 2 Sep 2021 19:06:04 +0800	[thread overview]
Message-ID: <CAD-N9QXNEOzqBtsTjeqYog4u3xP1r10ZC2hJWOxhLPFP-5-Stg@mail.gmail.com> (raw)
In-Reply-To: <911af8f1-d654-b4e1-1aac-c8a7ff94f6da@xs4all.nl>

On Thu, Sep 2, 2021 at 6:49 PM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
> Hi Dongliang,
>
> On 02/09/2021 12:23, Dongliang Mu wrote:
> > On Fri, Jul 23, 2021 at 6:11 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
> >>
> >> On Wed, Jul 14, 2021 at 11:23 AM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
> >>>
> >>> stk_camera_probe mistakenly execute usb_get_intf and increase the
> >>> refcount of interface->dev.
> >>>
> >>> Fix this by removing the execution of usb_get_intf.
> >>
> >> Any idea about this patch?
> >
> > +cc Dan Carpenter, gregkh
> >
> > There is no reply in this thread in one month. Can someone give some
> > feedback on this patch?
>
> I saw that it was marked as Obsoleted in patchwork, but I might have confused
> this patch with similar, but not identical, patches for this driver.
>
> I've moved the state back to New.
>
> Comments follow below:
>
> >
> >>
> >>>
> >>> Reported-by: Dongliang Mu <mudongliangabcd@gmail.com>
> >>> Fixes: 0aa77f6c2954 ("[media] move the remaining USB drivers to drivers/media/usb")
> >>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> >>> ---
> >>>  drivers/media/usb/stkwebcam/stk-webcam.c | 1 -
> >>>  1 file changed, 1 deletion(-)
> >>>
> >>> diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
> >>> index a45d464427c4..5bd8e85b9452 100644
> >>> --- a/drivers/media/usb/stkwebcam/stk-webcam.c
> >>> +++ b/drivers/media/usb/stkwebcam/stk-webcam.c
> >>> @@ -1311,7 +1311,6 @@ static int stk_camera_probe(struct usb_interface *interface,
> >>>
> >>>         dev->udev = udev;
> >>>         dev->interface = interface;
> >>> -       usb_get_intf(interface);
>
> Even though this increments the refcount (which might well be unnecessary),
> it is also decremented with usb_put_intf. So is there actually a bug here?
>

Yes, if the increment and decrement of refcount are balanced, it's fine.

But this probe function only increases the refcount, but forgets to
decrease the refcount.

> And if this is changed, then I expect that both get_intf and put_intf should be
> removed, and not just the get.
>
> Regards,
>
>         Hans
>
> >>>
> >>>         if (hflip != -1)
> >>>                 dev->vsettings.hflip = hflip;
> >>> --
> >>> 2.25.1
> >>>
>

  reply	other threads:[~2021-09-02 11:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14  3:23 [PATCH] media: usb: fix memory leak in stk_camera_probe Dongliang Mu
2021-07-23 10:11 ` Dongliang Mu
2021-09-02 10:23   ` Dongliang Mu
2021-09-02 10:39     ` Greg KH
2021-09-02 10:54       ` Mauro Carvalho Chehab
2021-09-02 10:59         ` Dongliang Mu
2021-09-02 11:10           ` Dongliang Mu
2021-09-02 11:15             ` Hans Verkuil
2021-09-02 11:22               ` Dongliang Mu
2021-09-02 18:14                 ` Pavel Skripkin
2021-09-02 23:51                   ` Dongliang Mu
2021-09-02 10:49     ` Hans Verkuil
2021-09-02 11:06       ` Dongliang Mu [this message]
2021-09-02 14:17     ` Dan Carpenter
2021-09-02 23:45       ` Dongliang Mu

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=CAD-N9QXNEOzqBtsTjeqYog4u3xP1r10ZC2hJWOxhLPFP-5-Stg@mail.gmail.com \
    --to=mudongliangabcd@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).