Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1041827pxb; Wed, 6 Apr 2022 07:21:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhDbUV+H6C/5xrkeV/SgJa+IczykvjWA/rIOHlYu7xJpUxSi7Lo3QWcDiN3CVGwphHntEs X-Received: by 2002:a17:90a:aa8a:b0:1c9:bfd8:9a90 with SMTP id l10-20020a17090aaa8a00b001c9bfd89a90mr10154607pjq.118.1649254868495; Wed, 06 Apr 2022 07:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649254868; cv=none; d=google.com; s=arc-20160816; b=bqG8jU09A1QGizn1WjJunFTBj5C0dqAko52PZbzXOfqNqCy3nGIjHns+ApxNw7/Ypk aqIIBG2PsZkNpU1j16T6dh05w2SMcUwtf12L88BL363/rt5SAa8bEuAoDW2Fe4z11s+N XOtF22bIOwvXHF8NTKv2Kwh9YqEUxCyurlfR/4nb+3aFGzI8KaEUFpU0P3jM6Vh0elFN wqihEzqrSRXyHjWuIlY+o1Aoulqjs2F3H/vXy4cfaJiWQbAXVtWj00ZxBHdAYC5ZZdz9 0jhZNwLiMqWCz16EF0Pz+9M+QHX641x7SAjhYFOaoElbC8DBC8lc2O0YPJDP1IaUACUn JKzw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=oaSJT2MCORoc9l270zc/rNeGHG600CBndNh2jLqXI2k=; b=jCle6fiJ8Z3kT7S5VOFmmY7jFgdyt/XV9dcKzagCnhHx2sBwcJoNTHKWD8KkplVhgq Krm4MO7p2vn01JFiQHGQ/LSO/VwSsxuJP+UjD8ymtR08DjN+FwfZlN5NjCVayrS9Smgu qwU+JP15TWOxW0MInTrhtNevsnZK2wz9DUj7+2Af1yZRU3Fs8hT6V6ERCBEESiG9j9Qv 9t3AJU34h0/jDc4noiKeSC+WKl/L9wPh8yPWqmVgQtnJD0/Fa/CWG0sVd+KSXV3Vlleo ObXvsXVDMX3J2z0L3Uc9wdxVzAY78jZlBAEpGXD6ST2ckHZK/gTDFI6hIe0qGxGxdIer gu7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ppfS2WNY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y4-20020a634944000000b003816043f10csi15502366pgk.769.2022.04.06.07.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:21:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ppfS2WNY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64A7523C0DB; Wed, 6 Apr 2022 05:06:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245672AbiDFLIm (ORCPT + 99 others); Wed, 6 Apr 2022 07:08:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239357AbiDFLHB (ORCPT ); Wed, 6 Apr 2022 07:07:01 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B1F3AC69F; Wed, 6 Apr 2022 00:34:01 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id j185so410868pge.4; Wed, 06 Apr 2022 00:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oaSJT2MCORoc9l270zc/rNeGHG600CBndNh2jLqXI2k=; b=ppfS2WNYcwLufDsPKLXAx0fCo7eYSEfFh+IH5vDLoBEPMdw97YFayX3c4LgtAkcRnD 1J6kH0fEJsM2DRUc7/PzeAMzqK2jaCzCj/ljEljC1fzO1XBkM8YWdGtxFCH02yR85Fof W+mLJidp62PnWFWKWHUvtlK30yLq3GmLpo6wsH7TugiuFINsCivuYbUNyItmNXqUVXSO rXN4QCvorksTyjnYy08HwdesuarmOmXS+MNxEWxPPk4c8rS6H5fX5bnxH1RLFwHQa0sl U/lSsF5XSRSQ8bJX72eF6qDtG59BQjB6L5sl7j8Q9dJOTu2Iy0WmPs7vaYP4XWOAtEAj IpZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oaSJT2MCORoc9l270zc/rNeGHG600CBndNh2jLqXI2k=; b=Dhszl4y/gz4dwZmDU9RYmCjNWbm4qVtJtGHa3PMoKXhbGY1Xk4sRWGrP8zOyMdYqL2 8NUkTIu8cmIo6G2xnipMIfEM3el3ObrInFB/YQGUe16OFUzDmePGxY0RaZ5wsApu5TfU DUIZnPDkeS00enFA82Wkq+4pG/RECEWTaviEH79OXrvptQQQl+Ef7kre/Oesq3ZSvU8q Joxc5kTA/e/JSlzie6ISoKOfKSl+QF/EBzykLkxGn2DguPRGl4DIAvE5YvbzzHeyPxzT iJ4dzwGFr4u3B1uddUqbSCnhiqixVULNvppeD8EspLxZuiv1faEE3ZDi9JSGNQUUvEjP C7dw== X-Gm-Message-State: AOAM532C0QHDUREx2+V6f4QCKVtIdhYLip5URrlRwp1oSrm24RXTkj0Q /0kwziyOlLtQp4m2XvIkRQoFL618WLAPQA== X-Received: by 2002:a05:6a00:174f:b0:4fd:aed5:b5e4 with SMTP id j15-20020a056a00174f00b004fdaed5b5e4mr7567585pfc.39.1649230440906; Wed, 06 Apr 2022 00:34:00 -0700 (PDT) Received: from slim.das-security.cn ([103.84.139.53]) by smtp.gmail.com with ESMTPSA id r10-20020a17090a454a00b001c96a912aa0sm4819711pjm.3.2022.04.06.00.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 00:34:00 -0700 (PDT) From: Hangyu Hua To: gregkh@linuxfoundation.org, mudongliangabcd@gmail.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hangyu Hua Subject: [PATCH] usb: misc: fix improper handling of refcount in uss720_probe() Date: Wed, 6 Apr 2022 15:33:49 +0800 Message-Id: <20220406073349.22203-1-hbh25y@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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. Fixes: dcb4b8ad6a44 ("misc/uss720: fix memory leak in uss720_probe") Signed-off-by: Hangyu Hua --- drivers/usb/misc/uss720.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 748139d26263..e243c155511e 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c @@ -736,7 +736,6 @@ static int uss720_probe(struct usb_interface *intf, parport_announce_port(pp); usb_set_intfdata(intf, pp); - usb_put_dev(usbdev); return 0; probe_abort: @@ -754,13 +753,13 @@ static void uss720_disconnect(struct usb_interface *intf) 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); parport_put_port(pp); kill_all_async_requests_priv(priv); kref_put(&priv->ref_count, destroy_priv); + priv->usbdev = NULL; } dev_dbg(&intf->dev, "disconnect done\n"); } -- 2.25.1