Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 800AF1CAA65 for ; Fri, 20 Mar 2026 00:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773965802; cv=none; b=NM2iSWVomGtiCIAOXX1/T87uVJHCBys4AHtvt1xrrZOe0FRDPvfqaIQtN/4grYjhqqMrg4/oGzy1DXiDHqECIpJUptAyziRxIR3fQVmCFBaXoOnfyJOHVfRV6w7oQe00zUMVPJxD0k3n0HVu4TfBPDXneh6JwTQwUBpEfYcQbus= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773965802; c=relaxed/simple; bh=6yE/rFdm0clviVs+9lAMyfpRWD2ThgTGDVg1DeXUwUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dzamwb0KONWhCE2xz9u4PLKg3nfwSRC8EvDanq5xxF2+1ksKvdDOLytLIyE+IyFZnpXSCLSO+1r+K+VRD2HaD/XiiMUaurBbfMtTNr+PhZ3Vo67vToYha6W5FOALvzJcVr5ZxIbSwc7DH9b6DUO9whNKNdBin84ppPFPNb+QMq4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NPVD2Yjw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NPVD2Yjw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73BABC19424; Fri, 20 Mar 2026 00:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773965802; bh=6yE/rFdm0clviVs+9lAMyfpRWD2ThgTGDVg1DeXUwUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NPVD2YjwFZ0CLOND/mnMqalG4Wv5QuFnYq5PSoiAo2uin5Fbp1j4As4jTU6TBdlyv pLe/V9hFoelt3a7Es1VXasbKR9W4KcNeKuHLjPvqp9/jskwlLcegjuYpVujVvnwI9n BcMxjT5OWRK+lFJAInZxYOjmna5+g/HgvvpFPmjEgcgrX5/m/l8CP4FBY+FBQMu6B8 F5VDM7rOxZXoOJGhl+DVY/x4edgLYDVQOo7Kw3n1PUOdGMZ9YKJk67b7ytgCSvwswn nkiXcPzieMcMSRF7rTtlviMiab28v7bfn+hlh5l+4+64Ha/bIJM54pXO1QnDxJcI8Z 89xc1PVv9T5ww== From: Sasha Levin To: stable@vger.kernel.org Cc: Antoniu Miclaus , Linus Walleij , Stable@vger.kernel.org, Jonathan Cameron , Sasha Levin Subject: [PATCH 5.15.y] iio: light: bh1780: fix PM runtime leak on error path Date: Thu, 19 Mar 2026 20:16:39 -0400 Message-ID: <20260320001639.3247800-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026031707-rehab-trio-c127@gregkh> References: <2026031707-rehab-trio-c127@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Antoniu Miclaus [ Upstream commit dd72e6c3cdea05cad24e99710939086f7a113fb5 ] Move pm_runtime_put_autosuspend() before the error check to ensure the PM runtime reference count is always decremented after pm_runtime_get_sync(), regardless of whether the read operation succeeds or fails. Fixes: 1f0477f18306 ("iio: light: new driver for the ROHM BH1780") Signed-off-by: Antoniu Miclaus Reviewed-by: Linus Walleij Cc: Signed-off-by: Jonathan Cameron [ moved both pm_runtime_mark_last_busy() and pm_runtime_put_autosuspend() before the error check instead of just pm_runtime_put_autosuspend() ] Signed-off-by: Sasha Levin --- drivers/iio/light/bh1780.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c index abbf2e662e7db..e0a72ff2ebf8b 100644 --- a/drivers/iio/light/bh1780.c +++ b/drivers/iio/light/bh1780.c @@ -109,10 +109,10 @@ static int bh1780_read_raw(struct iio_dev *indio_dev, case IIO_LIGHT: pm_runtime_get_sync(&bh1780->client->dev); value = bh1780_read_word(bh1780, BH1780_REG_DLOW); - if (value < 0) - return value; pm_runtime_mark_last_busy(&bh1780->client->dev); pm_runtime_put_autosuspend(&bh1780->client->dev); + if (value < 0) + return value; *val = value; return IIO_VAL_INT; -- 2.51.0