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 4B49E44607D; Tue, 21 Jul 2026 15:48:08 +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=1784648893; cv=none; b=mXK8lWLhs9fhpP/3NKz8bh86MVnauNwfNlOAN6O3KXEomHppadtDT/qxW/FKRwiqjfVE/Gm2sGOjRewdlj5jw+21Rnr3uem6dUmfCK4KdUdWcwCW70+0zM+Cp9NnoBMmuBrEVZqljsopkjx3haTE4R0i6IVT0K6yF0wQY68q+nA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784648893; c=relaxed/simple; bh=pYhS6EIVWqsVlCF47RjYSSpvEmxzN0DKPFqII9Pfv+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lQ4BZqcW5Ha8RucKcmb3gVy8etv+667t7ShhiOEy3QOi5JSxwJHpIxsaTuwAwF5em0Q2CJddk6Lpuh242d481JffP3VKp2V4JAKS0Z1+V5Hl+RqwqtoZlqhBURrhU4vIn+h/J0jKyMobOyt6Ip+21Bt9vz43+GPatxqVGJj5CGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rgcbQ4Ko; 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="rgcbQ4Ko" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1852C1F00A3A; Tue, 21 Jul 2026 15:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784648886; bh=A22w0IOE8zlkfE3DVjwkotETU7v0r4lADzouL5zowhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rgcbQ4Ko3QPbXRq7wyPsWToI1AgYKi2cNvKqE6Oc4+k8JxByMpmRjeQXMEGnZWKz3 RnKp4hw1fsYhiTVORVHhQCw6krgAI3NDSQRlMPTpoAyBqS6g43EBVeuDodereex0y/ rpkA/kd52W4GFZIX9+y4N1tk6iSFbwB69A073Su4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Alexandre Bounine , Chul Kim , Matt Porter , Andrew Morton , Sasha Levin Subject: [PATCH 7.1 0362/2077] rapidio/tsi721: prevent a bad dereference in tsi721_db_dpc() Date: Tue, 21 Jul 2026 17:00:35 +0200 Message-ID: <20260721152601.225894899@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@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 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit fc15e3a30ddd950f009c76765331783b9af94a87 ] With a list_for_each() loop, if we don't find the item we are looking for in the list, then the loop exits with the iterator, which is "dbell" in this loop, pointing to invalid memory. This code uses the "found" variable to determine if we have found the doorbell we are looking for or not. However, the problem that the "found" variable needs to be set to false at the start of each iteration, otherwise after the first correct doorbell, then everything is marked as found. Reset the "found" to false at the start of the iteration and move the variable inside the loop. Link: https://lore.kernel.org/af2WHMZiqMwdYveO@stanley.mountain Fixes: 48618fb4e522 ("RapidIO: add mport driver for Tsi721 bridge") Signed-off-by: Dan Carpenter Cc: Alexandre Bounine Cc: Chul Kim Cc: Matt Porter Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- drivers/rapidio/devices/tsi721.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c index 66331e67cf4efc..71b87bf8c31d85 100644 --- a/drivers/rapidio/devices/tsi721.c +++ b/drivers/rapidio/devices/tsi721.c @@ -394,7 +394,6 @@ static void tsi721_db_dpc(struct work_struct *work) idb_work); struct rio_mport *mport; struct rio_dbell *dbell; - int found = 0; u32 wr_ptr, rd_ptr; u64 *idb_entry; u32 regval; @@ -412,6 +411,8 @@ static void tsi721_db_dpc(struct work_struct *work) rd_ptr = ioread32(priv->regs + TSI721_IDQ_RP(IDB_QUEUE)) % IDB_QSIZE; while (wr_ptr != rd_ptr) { + int found = 0; + idb_entry = (u64 *)(priv->idb_base + (TSI721_IDB_ENTRY_SIZE * rd_ptr)); rd_ptr++; -- 2.53.0