Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1702042iob; Thu, 5 May 2022 06:47:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv+GdYPgngQvepSbEkRvxAqD1bQ/6x6ieYy/Izpvz+5T8Ujz7M/IKuQntk1jipWYv5gs1K X-Received: by 2002:a05:6402:84a:b0:426:262d:967e with SMTP id b10-20020a056402084a00b00426262d967emr30289890edz.286.1651758444330; Thu, 05 May 2022 06:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651758444; cv=none; d=google.com; s=arc-20160816; b=jKVdWDFnT0tHYFXSurYGZPQjrXVMJhOTrN2xgJCXoL5xj4wbqItzN2lEbNBJYAYgYS xAcvbs8G8leLDDJ1GMAKw+hWDn4yg8fEH0TQojX/GWE7Mm8Ps8o6RKFMDxbL/nB2D7lp z4AeAtFkmc78xP8k3OLyHyb6OsIuLOiE54JiErr6S8v2bSPPEvQslFLVVwTr7B2KrZf6 liVYocanw5Dn5BK9I3osxIst2HnWlcj5sxgJoFZvwtAqiKqCtmKPF8uml/tAa0MBmMA1 u3bN7tSQPOGObP8JMDao//2/yPji6ugiNKjUk2eXeqYGlGkBODqIxInrx0sWcRpKAy69 epxQ== 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=bJ+plbW9gqQFQi2ro7tXViiwXj5WeN9R6I35KQlrsPQ=; b=o86NV29GriM//9iROMwQM/Zx5zwF6lJnZDb5BFEgn4m1MPH7ne/tLlPnKWrSmNArxf TD/iGnt+02X0xFQUCwXGfgWiFC1CdUm9Jlxc+VnUhGJ6dZx+CODm3H8T/Bk/BfJiU4sS E7wb2FBmrZ6T/7rgefBdizyyQf5LbyoS/udhCDGF4b+EdIA7IvXUwBJcCJyrr95Aqy7y +bcPYK6duW9NcRoEfNoe5o2xG9gee/KdZNs+sUrvAIu4YbpK1wLCNZf1Jzl+ZKXPXXwJ Dc64RBUlXpipIZlNMOWXdr1ohGgi9ngs1CLGg+i14D3M5ngUeqtAUyWH9SmbyWpndYgn OHxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q7plFIHg; 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 e21-20020a170906315500b006f47e8eaf84si2281661eje.645.2022.05.05.06.46.59; Thu, 05 May 2022 06:47:24 -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=Q7plFIHg; 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 S1344128AbiEDRVY (ORCPT + 99 others); Wed, 4 May 2022 13:21:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355111AbiEDREI (ORCPT ); Wed, 4 May 2022 13:04:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 458664E382; Wed, 4 May 2022 09:52:45 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 27F0C617DE; Wed, 4 May 2022 16:52:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 772A2C385A5; Wed, 4 May 2022 16:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683164; bh=9E39mHLbOPtkiWOEOKFy56IbZL3g5wvMyD0A5kF6R7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q7plFIHgIAGNeYsW4s2Ipi65QK9KsX3Cd7RDY30gljkdyzvhHXRxX7OynSdR2N6ZB NBKmWJVylA6c7ykJJc7ChBt6R14vWV4OMd1eD+lFHtvMXICB6iuZALYUC2ZS3+ixgj UEpP7R+sObMzx2YHgrdGnB9w6TyJN+h88MIG568Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Dongliang Mu , Hangyu Hua Subject: [PATCH 5.15 016/177] usb: misc: fix improper handling of refcount in uss720_probe() Date: Wed, 4 May 2022 18:43:29 +0200 Message-Id: <20220504153054.873494597@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@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=-7.7 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=unavailable 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 commit 0a96fa640dc928da9eaa46a22c46521b037b78ad upstream. usb_put_dev shouldn't be called when uss720_probe succeeds because of priv->usbdev. At the same time, priv->usbdev shouldn't be set to NULL before destroy_priv in uss720_disconnect because usb_put_dev is in destroy_priv. Fix this by moving priv->usbdev = NULL after usb_put_dev. Fixes: dcb4b8ad6a44 ("misc/uss720: fix memory leak in uss720_probe") Cc: stable Reviewed-by: Dongliang Mu Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20220407024001.11761-1-hbh25y@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/uss720.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c @@ -71,6 +71,7 @@ static void destroy_priv(struct kref *kr dev_dbg(&priv->usbdev->dev, "destroying priv datastructure\n"); usb_put_dev(priv->usbdev); + priv->usbdev = NULL; kfree(priv); } @@ -736,7 +737,6 @@ static int uss720_probe(struct usb_inter parport_announce_port(pp); usb_set_intfdata(intf, pp); - usb_put_dev(usbdev); return 0; probe_abort: @@ -754,7 +754,6 @@ static void uss720_disconnect(struct usb usb_set_intfdata(intf, NULL); if (pp) { priv = pp->private_data; - priv->usbdev = NULL; priv->pp = NULL; dev_dbg(&intf->dev, "parport_remove_port\n"); parport_remove_port(pp);