Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1269958pxb; Wed, 6 Apr 2022 13:12:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg8mt/VLSPTk7kACOpmy48x1LVNWQb4ifQgM0xhw2i8jNoiFZa4yqqenjOeHDOD1u4s0Nv X-Received: by 2002:a05:6a00:2405:b0:4e1:5008:adcc with SMTP id z5-20020a056a00240500b004e15008adccmr10342514pfh.35.1649275973398; Wed, 06 Apr 2022 13:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649275973; cv=none; d=google.com; s=arc-20160816; b=MpL3d+ZOyO0MOshsIRpqpddjUnOvjZD1nP8cGaorO8hynw2pYBgjQVLhWJym9fmwJo C/taU/2mSisMQ4l+OTrQA+LtOVhpLT1gt3kvFax5WVIA9uzVl6XNK4TZY6fvWn3ALdoU s5vHZIyzCRgkI53JpcOE/Lx0ikiDn0rxgBeIEum6jQPnKwGlPG0MMF05cvNavVU13akg GKscUCPz33gMyt4Q0o32T4x/BVOiqpkT8QKJVlHlcH3OE1Cfp5L5RKYiLUOiMPOQ2w1n bRL8j0mSFqRYE9+6gfjteTswq8aD0v6PX6+n///6LoDImfnk2Zsa3EUK72Nz3j2hgp9N Jagw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=0OCy6LDYOIaS0T1WcEa+rwDReqz2SxY3oGp8Y6a/ndc=; b=xSMkuZ3t86HNDK4j4HDtrGArQfS4CQ3b35+Vl69CdDMZBjZEA9X1uVXuAqUztIjjtd tR9beby4OxMj7/cY0kA0+Ho1jMGuCzUYaUO0ZccbuhOqJ4kER68QWSgBTuZH1VO6oJ0b ockM+gikLLIn1uy1m5PzQO2pxLnFy/NwBWVg+RnjCMIgxWNbfGvb98sR8Fl5V8eXz2lb oDqoBh5kFrrCwTWxfNzlHNKM7yfhHkgU62IQVc4kyHzuByLuEYhll0hgJq+cpAIWmUch QkL8Hcsrzhx/bris7UanYfGkX2bgSRo4QK8pqZb8GUOh1Qj3NCvTAN2ml1WOuXaLUTRs kgiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=fUL21+aV; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa17-20020a17090b1bd100b001c6f45042dcsi5777381pjb.5.2022.04.06.13.12.38; Wed, 06 Apr 2022 13:12:53 -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=@linuxfoundation.org header.s=google header.b=fUL21+aV; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233278AbiDFT7D (ORCPT + 99 others); Wed, 6 Apr 2022 15:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233999AbiDFT62 (ORCPT ); Wed, 6 Apr 2022 15:58:28 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5029EB0A5 for ; Wed, 6 Apr 2022 11:14:00 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id 125so3913461iov.10 for ; Wed, 06 Apr 2022 11:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=0OCy6LDYOIaS0T1WcEa+rwDReqz2SxY3oGp8Y6a/ndc=; b=fUL21+aV9GSqoqJkETQjlSLoHe+M9P2mRn+vKYS1qWwmVQrbKUlsMi1coUdwgaFQkZ WnX4p9HYOr5jPZ2YJRw/G4PrtQQqR7OCaHeROXcO0Di2ozo/ZoxCl4KtEn1UInHPGIAd Eu4o4NFOCIRaTAgpNSW1rCVz/FZL4C4/20pYw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0OCy6LDYOIaS0T1WcEa+rwDReqz2SxY3oGp8Y6a/ndc=; b=8MZylkvp5zDV3CURkv8nEAGhjoym6vLeRhGDuqc70e/KUgQM86XAYgmvZil1Cfo75J vVTYecwuv+30CZR/EvOXRXkyWL3gdszJZ0NXtz2Wk9VJPHoANFy1QUb5dHL+x+c9Sv2Z FPkxOwp80oNZ0QXtsuWS1K2MKVGho925+OKaxe96HSr13uBYpERrq4KpH95pWA66j/vb YKELOgx94UCz3LqihNEc4OLJVjDLqm4Zn5K6s5wH25SamPB1umwyOvidqG4woaRX1+Mz TWpg2wHETKi4/mGkQp/E/mOaIzX2uh84GKpCjymAXabtu7H1uS/QnxSadrTxdqmvibKH LC+g== X-Gm-Message-State: AOAM5329cVP9uXCGO7PiKncv82kH5xuOoGLj/mFm2Ny4JMPGyCDE3JMS Biv4X93CKyu/DJX3Q25aFC+m3w== X-Received: by 2002:a05:6602:2aca:b0:646:a866:9fd4 with SMTP id m10-20020a0566022aca00b00646a8669fd4mr4829331iov.92.1649268838737; Wed, 06 Apr 2022 11:13:58 -0700 (PDT) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id f20-20020a6be814000000b00649d9a4db2asm11145251ioh.27.2022.04.06.11.13.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Apr 2022 11:13:58 -0700 (PDT) Subject: Re: [PATCH] usb: usbip: fix a refcount leak in stub_probe() To: Hangyu Hua , 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, Shuah Khan References: <20220406061713.18938-1-hbh25y@gmail.com> From: Shuah Khan Message-ID: <4341150b-195c-a896-1f6a-8715bbb539e2@linuxfoundation.org> Date: Wed, 6 Apr 2022 12:13:57 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220406061713.18938-1-hbh25y@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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