From: Gowtham S Bhushan <gowtham398gs@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Gowtham S Bhushan <gowtham398gs@gmail.com>,
syzbot+41172204e7323356ecdb@syzkaller.appspotmail.com
Subject: [PATCH] spi: core: do not WARN on OOM spi_controller_id_alloc
Date: Sat, 31 Oct 2026 08:09:42 +0530 [thread overview]
Message-ID: <20261031023942.591298-1-gowtham398gs@gmail.com> (raw)
In spi_controller_id_alloc() (drivers/spi/spi.c), idr_alloc()
can return -ENOMEM when radix tree memory allocation fails
under memory pressure or fault injection. The function
inappropriately invokes WARN(id < 0, "couldn't get idr") on any
failure rather than handling expected runtime allocation errors silently.
Modify the error handling path to only trigger a WARN when the failure
is due to reasons other than an out-of-memory condition (such as -ENOSPC).
Reported-by: syzbot+41172204e7323356ecdb@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=41172204e7323356ecdb
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Tested-by: syzbot+41172204e7323356ecdb@syzkaller.appspotmail.com
Signed-off-by: Gowtham S Bhushan <gowtham398gs@gmail.com>
---
drivers/spi/spi.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 40cda0037ea5..a1276d194465 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3631,8 +3631,17 @@ static int spi_controller_id_alloc(struct spi_controller *ctlr, int start, int e
mutex_lock(&board_lock);
id = idr_alloc(&spi_controller_idr, ctlr, start, end, GFP_KERNEL);
mutex_unlock(&board_lock);
- if (WARN(id < 0, "couldn't get idr"))
+
+ /*
+ * Modify the error handling path to only trigger a WARN when the failure
+ * is not due to an out-of-memory condition
+ */
+
+ if (id < 0) {
+ WARN(id != -ENOMEM, "couldn't get idr");
return id == -ENOSPC ? -EBUSY : id;
+ }
+
ctlr->bus_num = id;
return 0;
}
--
2.56.0
reply other threads:[~2026-10-31 2:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261031023942.591298-1-gowtham398gs@gmail.com \
--to=gowtham398gs@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=syzbot+41172204e7323356ecdb@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®