Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp698065pxb; Thu, 2 Sep 2021 12:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwepVMAV4HTt9BW5Os87P0Gp3Pu+RmLVIrHZF50N96iiQBGcXZlsK9BuzY7/spMeYloxGkG X-Received: by 2002:a02:7709:: with SMTP id g9mr4319763jac.104.1630612546274; Thu, 02 Sep 2021 12:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630612546; cv=none; d=google.com; s=arc-20160816; b=ATgUr4gW8z+Hv70/bigpXTOv3+kdrGlk9+RmTwd59HLL7KjcMRAfyPBcOmJuxRx8b7 JuTRYRh9tyNjbnJqRvgEEJPK3pfwxmqsK7Zfq/mtow6EvgH0Xc0VOC8praTpga6muj4b ++j0COeKWpSZBDnWZALdwyNPhC9++ebKC63mnRZ3qnO/AZ1kdsj59ukTH0Hw/QN8Eays tZI0RaB47SFoF2XfNMJgefFP2YKhTe0A2DvA12i3fvPo/Fyrnm/iqsNjofQV8V7kNkXU orspIXJDlKWiZxWAj/TrT3oZ97fm7kLonk8hO5PYG3fijxTHiAufngbnMHxfasGqpaRH cEIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KOq4nllLh5nZXSivVcNUZtzqdNbccqG98u+Oh9OcI7c=; b=zGKM5N3tNPVOikoxiciZllBbSp5z5itC2B5WL73BLzQyvXEpZxBn7M5REfQuzAW9OJ nLOHXGFfEQLQHGEwxZ7f+QZoXJcCYL1Te/BcuSMVsB9gYSc6S1HVaOTCzQeQ1jA9bSa1 TWcIKZMDd8Nnbk/7M8A55QrZXGsPZZmR/M963B/OpLYDRmk+Xts7p20bNiuNBze+QhyI gRAu+6vTBiojscZHhW6yeFoGEK/14armLMhyrw6apgLHNijnw9Y4y+rMurhT9CyaNTe2 OrVwQfYt9lAsSS0KpWAdRsV1Sk/kIPAMugolwksi0ml9CyTfxv7/QTbpIiALQvfFSP8R Ho1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kgrlG1Ml; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c193si2943436jac.53.2021.09.02.12.55.34; Thu, 02 Sep 2021 12:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kgrlG1Ml; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243090AbhIBLHe (ORCPT + 99 others); Thu, 2 Sep 2021 07:07:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbhIBLHa (ORCPT ); Thu, 2 Sep 2021 07:07:30 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAF0FC061575; Thu, 2 Sep 2021 04:06:32 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id e21so3358182ejz.12; Thu, 02 Sep 2021 04:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KOq4nllLh5nZXSivVcNUZtzqdNbccqG98u+Oh9OcI7c=; b=kgrlG1MlMqTFVM4smTwIwF0VzikXT0jLePq+LZWcErE7Nn/SpNupepUznxJw8Gj6Vm aFMGSJ/mGI1Rmf26vjQ1Jv5PyUdCMjfcDoYPAzOit0qn2nqMV+sTkry1ea4lxvzVOEkW LemewKUmGuN+yO9XpWDDN+jGTyHO8JNYkuU3tz75nJ6uXpwdwwGLM/b/m3E9lEGysJWd QHKHHFNCBWVQtObpo7YHoFFjprkEAzdg5PGpiAQEFNhnvWouByNE1ojIu5SEwX5j3XhV ShxRiL3ee0DL/ODgcHotH5enfGp7EzucbdYWfjTXxQnSpfmmGFulonCyIt3lC/DoDxMM P/DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KOq4nllLh5nZXSivVcNUZtzqdNbccqG98u+Oh9OcI7c=; b=FSFZKJFWiBhcb0P2Q9I3DNZkfIcsS6ZaLNf/3lMJte6CKwWj4uPPskvv7msZJv3LKz PJQrGZTet0lPpIqicnjs0zSZxpuk4zVOW9pXxkivp3UKArBgpHzHtDi3YpbRoJhxCrU7 zrk/jwgBwp9kdikCEHP6JWWm6YPeCwZwt0V8jf8K9CtwI2eLZT7PoYhmTgv0CpVGQMpw zMO0Zo3aPCYBKLBuoMSsHqgmNGigJB957vMInkNkgytYMegSlrWVgjq1naJLU6pfznAr 1Y8Ybuyg+J/Azf/h5a24u3n23v03Bh6q5KTGMcUm0m6RfPSpv6GLjaqJLR7/5XuCnAh3 MZ0Q== X-Gm-Message-State: AOAM530saWUWlPX9hG5fL01id3QLcxoseawIS8PzuPACu6HF5JPYfnqK gxs6nC08WeUPGZUPVAN23G6Fks+bSWG2fCzsYUI= X-Received: by 2002:a17:906:31ca:: with SMTP id f10mr3333730ejf.73.1630580791214; Thu, 02 Sep 2021 04:06:31 -0700 (PDT) MIME-Version: 1.0 References: <20210714032340.504836-1-mudongliangabcd@gmail.com> <911af8f1-d654-b4e1-1aac-c8a7ff94f6da@xs4all.nl> In-Reply-To: <911af8f1-d654-b4e1-1aac-c8a7ff94f6da@xs4all.nl> From: Dongliang Mu Date: Thu, 2 Sep 2021 19:06:04 +0800 Message-ID: Subject: Re: [PATCH] media: usb: fix memory leak in stk_camera_probe To: Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel , Dan Carpenter , Greg KH Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 2, 2021 at 6:49 PM Hans Verkuil wrote: > > Hi Dongliang, > > On 02/09/2021 12:23, Dongliang Mu wrote: > > On Fri, Jul 23, 2021 at 6:11 PM Dongliang Mu wrote: > >> > >> On Wed, Jul 14, 2021 at 11:23 AM Dongliang Mu 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 > >>> Fixes: 0aa77f6c2954 ("[media] move the remaining USB drivers to drivers/media/usb") > >>> Signed-off-by: Dongliang Mu > >>> --- > >>> 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 > >>> >