Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp617584iog; Mon, 13 Jun 2022 09:14:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkQth10Ram7pxhkXtP7t84h+9A9U5oUbro9v/xDoBrWOFxPxi44nFA7vG8UHKBdIcxX6Tn X-Received: by 2002:a17:90a:eb11:b0:1e6:7865:4ecb with SMTP id j17-20020a17090aeb1100b001e678654ecbmr16548185pjz.172.1655136872119; Mon, 13 Jun 2022 09:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655136872; cv=none; d=google.com; s=arc-20160816; b=o9K3DXE2BsSiiFR3lEHQ5sZgKibfIJOH8eEyXkUG/q00sfIozRVmXkK07DWPVMAmIo Qb15pGopGVRdEBqH0DCE9vR7yjh8GexASDLvCoMk994r8mHCvbp8XwclZe8XqsuheiiY T53ycVBb7HJ91XRTn3SbacFgM6UE2pseFZNn3xVCiJ3uEF7EYdhDnzf5TMdkuONEy1z0 nVIeOjdWmPgNPKy6Cl7lTfFZZn/ssSohWAVHJPqZ/XLwoGKMt5w/bOuPHjsJNkfAkJWS YKOP9K+6A4JojWFKc4imOjISnoP8gnF8xQFTtIu5DLq3DfKvfKw8CW2d3W8A1nzK3Fj9 tb4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FcMrrS76nqaoOWnV7CAygz0SegU1DWOQHh/weLThqSc=; b=lC1raAOLnwH/aR0lA3sL9AGdwZdCzb9sLbaTGzUrjlwJY3zwZpVuDeOGiDV37lv9SK JEbmobjn+e/zkHN8rUK2/vg/Sm+OluxofsP6Ssx3Urs5SgOM6881jZIYV3ccdvNfH9BC nA5s4Qk5kUcPPLvZjCEQb2c6TNErbpp05oA7iLM/o+Qfeo4QiTbtvgDX2ph4gqHsNVuq En1f81wLAuJY8Poj5NtujRwPRZbDcKX0P9TsjXwFr8l3zkzxWuT8g/Pq0W2elFx2m6K1 GJqNa4Xyk+LstNKsBb0uZ1PJuhtFXijuJQg69UD9FzWStPG8DAWf82V4+mi6HFGp4VrV iEJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MaxSj39q; 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 17-20020a631251000000b003db8a209973si523057pgs.404.2022.06.13.09.14.18; Mon, 13 Jun 2022 09:14:32 -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=korg header.b=MaxSj39q; 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 S1358639AbiFMMHl (ORCPT + 99 others); Mon, 13 Jun 2022 08:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359164AbiFMMFW (ORCPT ); Mon, 13 Jun 2022 08:05:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1CE2186C8; Mon, 13 Jun 2022 03:59:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 69352B80E92; Mon, 13 Jun 2022 10:59:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A8EAC34114; Mon, 13 Jun 2022 10:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117959; bh=1yjKjTzcT1Zx3cO1HUO1ozBdecc6lgMHL6Fc+Gj3GjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MaxSj39ql2tKv54h2OY1k0oPoZGVsSI6SoplgxyVlx09QsWq5ML8SA1LsAT0T8RUG eFq/2T5nkFarJYsabUbIeKmGB8nMbZYf4ANZ3cBVDXVmMZkvItsBKta37qCIQ4Bheb ezHXn4rwWXN1IWoCXv4JUwfJg9lGE417iqBCQckY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , Hangyu Hua , Sasha Levin Subject: [PATCH 4.19 192/287] usb: usbip: fix a refcount leak in stub_probe() Date: Mon, 13 Jun 2022 12:10:16 +0200 Message-Id: <20220613094929.688447577@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094923.832156175@linuxfoundation.org> References: <20220613094923.832156175@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Hangyu Hua [ Upstream commit 9ec4cbf1cc55d126759051acfe328d489c5d6e60 ] 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 error path handling. Find this by code review. Fixes: 3ff67445750a ("usbip: fix error handling in stub_probe()") Reviewed-by: Shuah Khan Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20220412020257.9767-1-hbh25y@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 0081c1073b08..c64964c32cc9 100644 --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c @@ -427,7 +427,6 @@ static int stub_probe(struct usb_device *udev) (struct usb_dev_state *) 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); @@ -442,6 +441,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; -- 2.35.1