From mboxrd@z Thu Jan 1 00:00:00 1970 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 DB65C296D09; Mon, 12 May 2025 17:53:41 +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=1747072422; cv=none; b=NDeN3CyE2oqQYFYVwvVOEGV6MgL/fr9c/WqHOQtI4v67T8rLqdZhiX6h3cqsKJrzdOP59dCvKrZQwStENax4rSNiPOIFFItyZmsdBs0DJrtzBwoB+HbFG1Nkm5CCfXKNFp6usz4pttApD4qcmCjDS+Lg3Bg3ps+Vpc29XIJn31M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747072422; c=relaxed/simple; bh=fPA7l7YCFHCRtGUnKswA/Kct4rE3ADxgwUUwRySZ+TY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KOp2jtgbutxljilLK9a/JyDItGpB8pxZK74yDLhWDb+JWC8E51GnL5rtlHVQ4/9MOdyZOPmwGK6cbLGDsrILpLf+dimHi77rsfWNqg99YC2/psRi4Z4Zbq/c+d6SuCk0ql57zhsHnOkz1yrx58qda7PKCBzwHDMedzJqfbQYqPk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Vkx2LHP1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Vkx2LHP1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53B09C4CEE7; Mon, 12 May 2025 17:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747072421; bh=fPA7l7YCFHCRtGUnKswA/Kct4rE3ADxgwUUwRySZ+TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vkx2LHP1diZzFnxmhOX+L5iK1A5SPwcTu4d68Q8ZA7Obxgraj0Wq8Q0bxFGb7T26c x6c60hDyRUJ+gOPupcYRk85xCdB6WKSzhOE+TlsKB085flrYhKugsBXFgGr+aH9tUZ VwuUyzOHhJFIj4gJ4UwfsQbrSirCbCa1sqp1KvEU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Silvano Seva , Lorenzo Bianconi , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 6.1 36/92] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Date: Mon, 12 May 2025 19:45:11 +0200 Message-ID: <20250512172024.598074935@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512172023.126467649@linuxfoundation.org> References: <20250512172023.126467649@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Silvano Seva commit 159ca7f18129834b6f4c7eae67de48e96c752fc9 upstream. Prevent st_lsm6dsx_read_fifo from falling in an infinite loop in case pattern_len is equal to zero and the device FIFO is not empty. Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver") Signed-off-by: Silvano Seva Acked-by: Lorenzo Bianconi Link: https://patch.msgid.link/20250311085030.3593-2-s.seva@4sigma.it Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -370,6 +370,9 @@ int st_lsm6dsx_read_fifo(struct st_lsm6d if (fifo_status & cpu_to_le16(ST_LSM6DSX_FIFO_EMPTY_MASK)) return 0; + if (!pattern_len) + pattern_len = ST_LSM6DSX_SAMPLE_SIZE; + fifo_len = (le16_to_cpu(fifo_status) & fifo_diff_mask) * ST_LSM6DSX_CHAN_SIZE; fifo_len = (fifo_len / pattern_len) * pattern_len;