Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp159430pxb; Thu, 7 Apr 2022 01:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXDyBnOFlQK+g9ZU8kBsYsOPZ5QH8C0QLPMBm495uvl0jbYnU1xb43rs8OfThnUDX5phhJ X-Received: by 2002:aa7:da57:0:b0:41c:df2e:c34 with SMTP id w23-20020aa7da57000000b0041cdf2e0c34mr13497682eds.207.1649321717142; Thu, 07 Apr 2022 01:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649321717; cv=none; d=google.com; s=arc-20160816; b=pok4NvToNKRmAERrrEcaT92GGvk0Li+Z+NOvwa90qbn11WxcQx8O8knjXaLQTTRnzi xHzqArPB+um2yzi6VIebnhMWLOaBgD9FmIpms6NRq9qMG9QHwK7lyAlm1683pzywae03 KQBdNHPWXEmde2fkAWrF+2ZQAp5OD7JraiUyL8fMWTcDgciONzN7f5pjZg+CnDzg4Z4o QgIOqh3c6LXWZCvR/uysSqKELqThZkorQlHRT1GkotAiEvOjs4Ab8XT7CL09XT8v8Xpn B3OeqV8Ua+fq0PGymoZPAycCagtif/fV0MgBl11J+S1R1EL5EJIz9ZTHPeMP5E2Zkg2t X0oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OOMAfdi8D5EciZ02glPhlmpRgH66ew4WPzL5EDA2QJY=; b=sZDflhutTj+URHLBhaTJETTjbXN2Iu6Jp6uPBlIOEf6JqopfnGoqovpz3gwGybhUU+ lV0XAlqEBUS312wR+I29NaDeU48mYqynVgyjt4GY3kRGnWYMwgkE9VtsanK635p7flrY AzSrLMYfYTxY6AS8N1gXWjLOUzNP8mY7VRzF89iTWz7S2GhxYF2aN3qzv3AdkiIdnrQ+ AiO+Bo1ClBevZe0XBWiKSeD1RoQQBC4chAOgiUuVnIdcp73lzQQjMriw+3oOtV3iP5RE IH7wyRzCgWPRTz7b0qpKFTWXmv4Q+JbtQsXSKqg/6iJZkgAm/dzF5JuhykWotxCwmE/U v3NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z791tYA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z23-20020a170906435700b006df76385ecfsi13708659ejm.879.2022.04.07.01.54.50; Thu, 07 Apr 2022 01:55:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z791tYA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233573AbiDGBpU (ORCPT + 99 others); Wed, 6 Apr 2022 21:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238932AbiDGBoh (ORCPT ); Wed, 6 Apr 2022 21:44:37 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2320D1226E1; Wed, 6 Apr 2022 18:41:53 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id q19so3698023pgm.6; Wed, 06 Apr 2022 18:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=OOMAfdi8D5EciZ02glPhlmpRgH66ew4WPzL5EDA2QJY=; b=Z791tYA6TNVIW3YGkEphF+I4hP02mwTPc+2B0nG1717AE3f3/lVLDkbFrzCefMaQ1a PTLvLfGLTt2LBu5AU6wUOq8QRl2Eu/diz4r2wtYxAbWKB0YaNB3ZopHroD6on/u7Q/Lw Gn24QLtQs9T6p6dNf6okTWosueuf8D+VAA++nBWcQUe9NKfD8hiILvBPVwWl3fI7r7HD J3ysgfoKbjSrd/B21ryRnsibDrpIH8pEBy+HsowTgv2QOF0yJBCCKbOpK/gbcS5nMFGs 38kW2NOM1b2/W1uvRfEssd454x8l+ueJfxB+PEnsQdMDgGv08wsDO0jmunEjSWLXCw3C jdfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=OOMAfdi8D5EciZ02glPhlmpRgH66ew4WPzL5EDA2QJY=; b=WFq1NhT/BJYhGUhpqVUWGNQJA6eh0exSDRd1lALpQaiswNODcl1aPGxzbVNNt+ep31 if49Y03bapm//HD1i2bxKeybnoCGWrWotBkyeQ2rdbGMFxfrSRGHf/X/1v0EjXkELQlx oxI686xwahtRYgZY6oZChDjQYeBfDKnrkNl8Fm6JgOKuEgXwyNqXa9qsti55arkIlmuE VB8ZqZ4Qj5uaItd6KT8jn7X1bwaab0makSIjdB1DJC3YBRn7jL8yA89Mi/0/yuieLowH IG4VDsx864lwGt5kNVT9J/abFr3KhPAjNoAJkkrx9FNJjT1/dpPAubAFUtYSTzwwBVZK SGkA== X-Gm-Message-State: AOAM531G4IcpCmx5aei1RnIlWiB5MdDLAq3DTy+zPWKUPeNrCE6iI54t xwbjKtGSke1o6h59yogY8bY= X-Received: by 2002:a63:3185:0:b0:39c:c854:34ae with SMTP id x127-20020a633185000000b0039cc85434aemr469773pgx.13.1649295712626; Wed, 06 Apr 2022 18:41:52 -0700 (PDT) Received: from [10.11.37.162] ([103.84.139.54]) by smtp.gmail.com with ESMTPSA id e10-20020a17090a630a00b001c685cfd9d1sm6720441pjj.20.2022.04.06.18.41.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Apr 2022 18:41:52 -0700 (PDT) Message-ID: <732eed82-18eb-c57b-fca1-e1f33f1f0499@gmail.com> Date: Thu, 7 Apr 2022 09:41:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] usb: usbip: fix a refcount leak in stub_probe() Content-Language: en-US To: Shuah Khan , valentina.manea.m@gmail.com, shuah@kernel.org, gregkh@linuxfoundation.org, khoroshilov@ispras.ru Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220406061713.18938-1-hbh25y@gmail.com> <4341150b-195c-a896-1f6a-8715bbb539e2@linuxfoundation.org> From: Hangyu Hua In-Reply-To: <4341150b-195c-a896-1f6a-8715bbb539e2@linuxfoundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks. I will send a v2. On 2022/4/7 02:13, Shuah Khan wrote: > On 4/6/22 12:17 AM, Hangyu Hua wrote: >> usb_get_dev is called in stub_device_alloc. When stub_probe fails after >> that, usb_put_dev needs to be used. >> > > Thank you for the patch. Please include details on how you found > this problem. > > Nit: Change this to: > > usb_get_dev() is called in stub_device_alloc(). When stub_probe() fails > after that, usb_put_dev() needs to be called to release the reference. > >> Fix this by moving usb_put_dev() to sdev_free >> > > Nit: Change this to: > > Fix this by moving usb_put_dev() to sdev_free error path handling. > >> Fixes: 3ff67445750a ("usbip: fix error handling in stub_probe()") >> Signed-off-by: Hangyu Hua >> --- >>   drivers/usb/usbip/stub_dev.c | 2 +- >>   1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c >> index d8d3892e5a69..3c6d452e3bf4 100644 >> --- a/drivers/usb/usbip/stub_dev.c >> +++ b/drivers/usb/usbip/stub_dev.c >> @@ -393,7 +393,6 @@ static int stub_probe(struct usb_device *udev) >>   err_port: >>       dev_set_drvdata(&udev->dev, NULL); >> -    usb_put_dev(udev); >>       /* we already have busid_priv, just lock busid_lock */ >>       spin_lock(&busid_priv->busid_lock); >> @@ -408,6 +407,7 @@ static int stub_probe(struct usb_device *udev) >>       put_busid_priv(busid_priv); >>   sdev_free: >> +    usb_put_dev(udev); >>       stub_device_free(sdev); >>       return rc; >> > > With the above addressed: > > Reviewed-by: Shuah Khan > > thanks, > -- Shuah