Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3870523pxb; Tue, 17 Nov 2020 05:52:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxs6UdIsH5gdRz/XAbln5Ek39zqR6qFL+YLQehlKRpAWVGEjm/zfqymUKHxGf/2lbJ6Yi7 X-Received: by 2002:aa7:cc8f:: with SMTP id p15mr22215155edt.240.1605621120285; Tue, 17 Nov 2020 05:52:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621120; cv=none; d=google.com; s=arc-20160816; b=Ps0gJRx8EmTWJrWMLacssvLPSCqzSJ2ViM9GlEnhM6iOdQla4lh+r3ZjW09/pFwWbJ aQYhYTrXTcYJjkNp6i6wfuraky5LIcGl+Ypx9NZ84qRNB9k+DLgbKYmUNc6b3mg1xaOm zGKEEWqwUwWSIEtFhSAcbtt+bTGtFvpybBpOkgiIb90MEaaL6iSsEFoFUkro6ab1xRlg nqMpK/B3xTWsn3OjWfgKZnnNofPB7rHluwSTx9+yA6jCz74NQ22Oi5uPJIWEf1DE4Zxc /bFmOLcsrrsdhZSwQw14HaCr+gytBNYA2+cIc8geMKVXGslc1czdeLm6CWSSXMmWCKwl eKVQ== 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=ToxRix/y/zU7VY/CA2GmXeLHBQF5cbaQBsFCCZIN0/U=; b=g1QazJ3mUWDtPHGduRI+Y5pgPnoUv9orpq0mTiyUZfAzTVBccEwrVMprOTREvMqtyF DKbVezTlEbMNtrH7BpM/WvfInLUmV/HcviiHCdJ6/JCCnmPP1xIY+0oiatbm6ilBhAlF T02mC6A9F6wbQrDjOcAstU9+k8DEbW8wvzRUURkm22o6igQCGIyujzj8u3/Q0DFWq5Ai UHYd2z1bxgTtoR/BHKsntPuC7St7FamLes8840OoOZzQ5gRpdnXorlYN6uLk3xLcTSxM 8bOxcWvGqQbbIPU/CYnmgWfi+8//DbSrhnbhGe+TSbLHhp/7DFveu28iZIyJDEatx5F2 Qt0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=la3Q6WFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si13146218ejd.391.2020.11.17.05.51.37; Tue, 17 Nov 2020 05:52:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=la3Q6WFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732800AbgKQNtx (ORCPT + 99 others); Tue, 17 Nov 2020 08:49:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:43056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732369AbgKQNdI (ORCPT ); Tue, 17 Nov 2020 08:33:08 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6EAD8207BC; Tue, 17 Nov 2020 13:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619987; bh=FhelXD50GTExay7XPYUh/K4uWzVw66OudU3KAuCU0ZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=la3Q6WFnVsmJlWbn/zasNlVh46xPb1B7suBzAU1NcUWmE1TO4fpp+CqINUIol8q22 vZsMoHT9YC03l9sZd6tiOR6Z2Y6Wamoy76UMPjr0BIppZgb2auLDA2bhJ51WRMGVDw j/Z+xPKAIFgOIYGAYFmJ+iwMdunHIsLWgf7/ZYhU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Sasha Levin Subject: [PATCH 5.9 071/255] USB: apple-mfi-fastcharge: fix reference leak in apple_mfi_fc_set_property Date: Tue, 17 Nov 2020 14:03:31 +0100 Message-Id: <20201117122142.405375545@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qilong [ Upstream commit 00bd6bca3fb1e98190a24eda2583062803c9e8b5 ] pm_runtime_get_sync() will increment pm usage at first and it will resume the device later. If runtime of the device has error or device is in inaccessible state(or other error state), resume operation will fail. If we do not call put operation to decrease the reference, the result is that this device cannot enter the idle state and always stay busy or other non-idle state. Fixes: 249fa8217b846 ("USB: Add driver to control USB fast charge for iOS devices") Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201102022650.67115-1-zhangqilong3@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/misc/apple-mfi-fastcharge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c index 579d8c84de42c..9de0171b51776 100644 --- a/drivers/usb/misc/apple-mfi-fastcharge.c +++ b/drivers/usb/misc/apple-mfi-fastcharge.c @@ -120,8 +120,10 @@ static int apple_mfi_fc_set_property(struct power_supply *psy, dev_dbg(&mfi->udev->dev, "prop: %d\n", psp); ret = pm_runtime_get_sync(&mfi->udev->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(&mfi->udev->dev); return ret; + } switch (psp) { case POWER_SUPPLY_PROP_CHARGE_TYPE: -- 2.27.0