From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E20B6471259; Tue, 21 Jul 2026 18:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784657066; cv=none; b=snwfmgdhYn5FFY4aDIGh9AQ8OihxguRHeSD/LabqV9/oS8GzyrNbYIVBZaiV4YCP9U4n2h9o/jWOi0OoCefmrExsw0xthqibpiNjCT9o9rQs7c/FRzjJP5IwVECO3k5KVV2AIjjW0/otDtfklCcTiFX+x5ekCdthTwq4z8DBsX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784657066; c=relaxed/simple; bh=MfDWXCii0k1l4O1jEabq3CET8qViJnMQAagSAgb+oRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BIILHWIa4BpKov4HB5v6++LZXMNmv77RtJCvc/MvU3kkAsOuxTVzVsRODyhrAPel3tBmTOz3pZsvO/vreNzou+8G9BocHA4UjHqt8K9W5MVyhpXUUA+Txm0lND6sB+JP1rLP/rnd5Ah+aoE8HLlysHDV4/mpx/lr9/7H42hOy4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FeGk9CVN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FeGk9CVN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 555C51F000E9; Tue, 21 Jul 2026 18:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784657065; bh=qMMD0wWknsmPZdMGzwU9N88IfB+z5p5eHzB2N1w8czE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FeGk9CVNLhUpmkw6Ln7vpcLhl4DFQuS3LXmAFkvU1IYkP6JqArUVPMDiswD/Yve0Y s/N4zRKXEqJTMY1iypI32jDvYfBnOkdJNBah3y7iEP01NK5tQQxMlg0ERAfzQRq1Hb zwkX9rqGRKhtUhyCwOGyLD6uGMQII1M+GrJwIIgo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sanjay Chitroda , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.18 0624/1611] iio: accel: mma8452: handle I2C read error(s) in mma8452_read() Date: Tue, 21 Jul 2026 17:12:20 +0200 Message-ID: <20260721152529.424443324@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sanjay Chitroda [ Upstream commit 5bdff291d20c31b365d9ddfe9c426fbfb41da5bb ] Currently, If i2c_smbus_read_i2c_block_data() fails but mma8452_set_runtime_pm_state() succeeds, mma8452_read() returns 0. As a result, the caller mma8452_read_raw() assumes the read was successful and proceeds to use a buffer containing uninitialized stack memory. Add proper checking of the I2C read return value and propagate errors to the caller. Fixes: 96c0cb2bbfe0 ("iio: mma8452: add support for runtime power management") Signed-off-by: Sanjay Chitroda Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/accel/mma8452.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 15172ba2972c59..cefc7cf4bd8353 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -252,6 +252,8 @@ static int mma8452_read(struct mma8452_data *data, __be16 buf[3]) ret = i2c_smbus_read_i2c_block_data(data->client, MMA8452_OUT_X, 3 * sizeof(__be16), (u8 *)buf); + if (ret < 0) + return ret; ret = mma8452_set_runtime_pm_state(data->client, false); -- 2.53.0