Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9394703pxu; Mon, 28 Dec 2020 15:04:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfhpaHPXwZeJP6AAHd5PHu+oXJB4EUxnd23Yp+hpuAX+ZhFaQK3yPVGiJG+jwe5PnLGxUN X-Received: by 2002:aa7:ca14:: with SMTP id y20mr9904178eds.340.1609196688884; Mon, 28 Dec 2020 15:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609196688; cv=none; d=google.com; s=arc-20160816; b=Tc/WFqa559Y14WQaeSGwYUst1AQIqPrlJPuF30J/Bm0fqWGCrdbDLhh5obJW0sSi/U DGo2YX+NjGTXEsiHuO2RL0rLhs6kPOXebr3WUsmupqYEqL6RAMSxP1Bnd+ylTeFaGiv8 J80wmxX6cwwpKEl7Fc87Hh2jxrA+RfFauHPnPVvy7jPv1aZ+2D9XYt++mvHlsc+roKyC ER5eKn01vWztPK8A/of9bRwlNpzgznIkGwgqcpTWXNUtn2Tx5YOFE3wYyRnWykX43Inu qY2VZD17OTgFJufDfLYNBzttQPwKzj0Nrw+duskHgo6Euen/AcIlUGVr8lmevAEy0XIY oP3w== 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=BCRuIye1chgm+HaNq1k2ocu4McQ2Ultfm0d4ey0Y308=; b=EXMThoZ2mmrRRYMmncwPyYiqu0PWnB/ZYKBMzDtbTC8+AYO0xhtvuqzFwz97TDGZsO HY1qubEGAdTEIzweDeCn884yK92QGi91FvjVbILNLyix/gXAVaEznconAbRI5/w9xS1m 2yeIHNd7Z5z/X/ttvZa7cKV3KBJufdCLuT4s+qLVb1C6Z2tLvEOAJWd2I21pcoAO3cat 4B+JkeA2nJDE/FbNHPHMe1/GTjQsSxHZR1Elukn9R/RCFTH6G1p49FhmrjLEv671Tli0 nFrAXOekRbscvTSlqZgrdNllG9nD5TIUJvRPQglg+IVBQsfgrJKv6tB6emAiFWNi3rdA 0FHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ujcyqzVo; 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=pass (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 j13si19174976ejc.454.2020.12.28.15.04.26; Mon, 28 Dec 2020 15:04:48 -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=@linuxfoundation.org header.s=korg header.b=ujcyqzVo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437373AbgL1OEb (ORCPT + 99 others); Mon, 28 Dec 2020 09:04:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:38394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437361AbgL1OE3 (ORCPT ); Mon, 28 Dec 2020 09:04:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C0032063A; Mon, 28 Dec 2020 14:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164253; bh=/2JmIDdhAKmZwE2B5eV/D4avkZ+BWKt4Rl0Qhwe9fyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujcyqzVoiCn4IsHMOBafsnLtEeWcrGJ91OwWPlOcZp8YICYFip9eHorjXYsxIQkGC 6I3WEncPFoVNGzdPtGFar7sc3dxY/0uATkleD0aai2+RfUovjpbtovzDGgyUsa93za WmQvBvL/QrHBSmyrMV/PWeQN1x+5Fe1BZlKZ5ZQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Patrice Chotard , Mark Brown , Sasha Levin Subject: [PATCH 5.10 075/717] spi: stm32-qspi: fix reference leak in stm32 qspi operations Date: Mon, 28 Dec 2020 13:41:13 +0100 Message-Id: <20201228125024.589079240@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 88e1419b5ee30cc50e0c4d5265bdee1ba04af539 ] pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to pm_runtime_put_noidle will result in reference leak in two callers(stm32_qspi_exec_op and stm32_qspi_setup), so we should fix it. Fixes: 9d282c17b023a ("spi: stm32-qspi: Add pm_runtime support") Signed-off-by: Zhang Qilong Reviewed-by: Patrice Chotard Link: https://lore.kernel.org/r/20201106015357.141235-1-zhangqilong3@huawei.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-stm32-qspi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c index a900962b4336e..947e6b9dc9f4d 100644 --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -434,8 +434,10 @@ static int stm32_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) int ret; ret = pm_runtime_get_sync(qspi->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(qspi->dev); return ret; + } mutex_lock(&qspi->lock); ret = stm32_qspi_send(mem, op); @@ -462,8 +464,10 @@ static int stm32_qspi_setup(struct spi_device *spi) return -EINVAL; ret = pm_runtime_get_sync(qspi->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(qspi->dev); return ret; + } presc = DIV_ROUND_UP(qspi->clk_rate, spi->max_speed_hz) - 1; -- 2.27.0