From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383281; b=VMcYZRbhiGuHf2fy6NkT1nvkEw+e1gIVc2X+A0Y5VpbREickfhOAic65ABKkGJ43rw/w uarJNLpPviyXdj19NhhoXmlMMKVJ1XoOhm6csr3o+ITRivHdzwuAmusq3tqSmQDyPIjHk ZfcS60Ji3iVSV62xGCXFpmWR/+hiWNiG2akyTcw7z3ofguU4cuQhyRWN7Z+5vBwgZfDDp cdaUa8t5tCoYhFORV8FQ3+w9zOM4GQQHw93cL5tXvvARsYbDyOEu48LUXYQTxsKGmC4Dk s/HfV6Gozn2IjvfEiEAuJzHfwB1WVSmjDbNj3T5XgSDyrA8n9GZrnIKnZOKTew/XM8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383281; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=j1ldRoVu1inAEDBoPK9tmTqFABREEgfF2JfRbUvGN6E=; b=U2K9ElDTH/u+1LKduZ0r/R/zqtQo3nQFEJeCEKFFjtT9yCjkLBgQ2IormSwUOxKmATGB l8BSSQcr6duthvvyTyDmDc9Gh5Om+IiLfADIzK20+igDF9OqC6O/3zJwNNaZ0XDmDkjHB I2Dugv/wgJS5aYL4S6F0ZnRR4ytASEcgq+E1Ert+osAnDd45TyBtzxzKgv324mMxEc5Dy AwjEs/Qv/Ey2xyZTODkXFHuomb+PRmmNCYxOSoRZFGhFxIVglQdVGkangU7xDG3aSodLk hMbL4qh6O2HY6RBP4jdF3j5OxvSjL8VmxBlx5hI5r7OvFOkeC7QVyQrDfiuggNKh/OQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=V03YVM1J; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A40A6606A332; Fri, 4 Dec 2026 11:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=V03YVM1J Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19DCB1F000C2; Fri, 4 Dec 2026 11:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383281; bh=j1ldRoVu1inAEDBoPK9tmTqFABREEgfF2JfRbUvGN6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V03YVM1JR+GhbisssEj5zCLDTkST69a5hN0RHSkV04TIVhKPEf23/qnw1bUtEMlc6 7eYesakKs3XPDOCzAwmIMgdrOLf/zo31m7K8S2KDouqzJfuwqYG167oGJ8fA7+k2iW uBv32+Qx9GVIwNgX9LDXJopMvoF+/5U64rhId/Tc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Moksh Panicker , Jonathan Cameron , Dickson Wu , Sasha Levin Subject: [PATCH 6.12 133/555] iio: light: apds9306: fix PM reference leak in apds9306_read_data() Date: Fri, 4 Dec 2026 19:02:56 +0900 Message-ID: <20261204100612.829055228@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Moksh Panicker commit d378fceaafd79e0dc59d3546bda251a3058062c0 upstream. apds9306_read_data() calls pm_runtime_resume_and_get() but several error paths return directly without calling pm_runtime_put_autosuspend(), leaking the runtime PM reference and preventing the device from autosuspending. Use PM_RUNTIME_ACQUIRE_AUTOSUSPEND() and PM_RUNTIME_ACQUIRE_ERR() to automatically handle runtime PM reference release on all return paths. Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor") Signed-off-by: Moksh Panicker Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron [ adapted to 6.12.y: no PM_RUNTIME_ACQUIRE helpers, goto the put ] Signed-off-by: Dickson Wu Signed-off-by: Sasha Levin --- drivers/iio/light/apds9306.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c index db648e2cb5200..5e483cf4dc153 100644 --- a/drivers/iio/light/apds9306.c +++ b/drivers/iio/light/apds9306.c @@ -477,19 +477,21 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg) ret = regmap_field_read(rf->intg_time, &intg_time_idx); if (ret) - return ret; + goto out_pm; ret = regmap_field_read(rf->repeat_rate, &repeat_rate_idx); if (ret) - return ret; + goto out_pm; ret = regmap_field_read(rf->int_src, &int_src); if (ret) - return ret; + goto out_pm; intg_time = iio_gts_find_int_time_by_sel(&data->gts, intg_time_idx); - if (intg_time < 0) - return intg_time; + if (intg_time < 0) { + ret = intg_time; + goto out_pm; + } /* Whichever is greater - integration time period or sampling period. */ delay = max(intg_time, apds9306_repeat_rate_period[repeat_rate_idx]); @@ -512,7 +514,7 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg) APDS9306_ALS_INT_STAT_MASK)), APDS9306_ALS_READ_DATA_DELAY_US, delay * 2); if (ret) - return ret; + goto out_pm; /* If we reach here before the interrupt handler we push an event */ if ((status & APDS9306_ALS_INT_STAT_MASK)) { @@ -532,15 +534,16 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg) ret = regmap_bulk_read(data->regmap, reg, buff, sizeof(buff)); if (ret) { dev_err_ratelimited(dev, "read data failed\n"); - return ret; + goto out_pm; } *val = get_unaligned_le24(&buff); +out_pm: pm_runtime_mark_last_busy(data->dev); pm_runtime_put_autosuspend(data->dev); - return 0; + return ret; } static int apds9306_intg_time_get(struct apds9306_data *data, int *val2) -- 2.53.0