Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>
Cc: Shawn Guo <shawn.guo@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Grant Likely <grant.likely@secretlab.ca>,
	stable@vger.kernel.org
Subject: [PATCH] misc: sram: do not allow unbinding the device
Date: Fri, 27 Nov 2026 20:42:17 -0800	[thread overview]
Message-ID: <20261128044217.723361-1-rosenp@gmail.com> (raw)

Other drivers allocate from the SRAM pools and map the reserved regions,
with nothing tying their lifetime to the SRAM device. Unbinding it
through sysfs destroys the pools under them: sram_remove() notices and
prints "removed while SRAM allocated", but carries on, and the devm
release of the pool then hits the BUG_ON() in gen_pool_destroy() for
the outstanding allocations.

Seen on an Armada 385 with the CESA crypto engine holding its buffers in
an mmio-sram region:

  # echo f1100000.sa-sram0 > /sys/bus/platform/drivers/sram/unbind
  sram f1100000.sa-sram0: removed while SRAM allocated
  Internal error: Oops - undefined instruction: 0 [#1] SMP ARM

The driver cannot be built as a module, so suppress the bind attributes
and with them the only way to remove it.

Fixes: 4984c6f5e56c ("misc: generic on-chip SRAM allocation driver")
Cc: stable@vger.kernel.org
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
An AI coding assistant (Claude Code, Claude Opus 5.5) was used to find
this while reviewing the CESA driver, reproduce it on the board, and
write the patch and its commit message.

 drivers/misc/sram.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index c5110c32f661..fed949de60f5 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -450,6 +450,7 @@ static struct platform_driver sram_driver = {
 	.driver = {
 		.name = "sram",
 		.of_match_table = sram_dt_ids,
+		.suppress_bind_attrs = true,
 	},
 	.probe = sram_probe,
 	.remove = sram_remove,

base-commit: 917fcbf033154a6c8d83cfa6c88f012b71eb37b2
-- 
2.56.1


                 reply	other threads:[~2026-11-28  4:42 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=20261128044217.723361-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=shawn.guo@linaro.org \
    --cc=stable@vger.kernel.org \
    /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