From: Arun Iyengar Subject: [PATCH 0/2] regmap: Fix bus context frees on init failure Date: Mon, 30 Nov 2026 20:21:20 +0000 Message-Id: <20261130-regmap-devm-ctx-v1-0-cfabbeaadee8@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yXMTQ5AMBBA4avIrE2ikyBcRSy0HTUSP2kRibi7Y vkt3rsgsBcOUCcXeD4kyDJHqDQBM3SzYxQbDZRRoRRV6NlN3YqWjwnNdiJVea41GZWVJcRq9dz L+R2b9nfY9chmezdw3w+gWYvtcwAAAA== X-Change-ID: 20261129-regmap-devm-ctx-2955bb2c1077 To: Mark Brown Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Johan Hovold , Krzysztof Kozlowski , linux-kernel@vger.kernel.org, driver-core@lists.linux.dev, Guenter Roeck , linux-hwmon@vger.kernel.org, Xu Yilun , Arun Iyengar X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796070081; l=1029; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=7IyTG9neOYjEwSRPDRGVYcf0HkHPqpiOzqe0u9jjxeg=; b=U9YaBrK9EWG0KFeh2j8Ge0vHDisAER/ZhudYiauCF1NZuRZB6D11paLn6tkAqvYOCl7NG0htP GAUtxex5KEeA6i3YWAGZfxMdfFI9jbER64yShtOu9JI+yxDTPk07D37 X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 List-Id: B4 Relay Submissions Since b1ef855c6260, a failing __devm_regmap_init() can free the bus context, so spi-avmm and sch56xx free it twice. Patch 1 restores the old behaviour. Patch 2 fixes the mmio context leak on init failure. Tested with failslab on an Orange Pi 5 (devm mmio regmap): kmemleak finds the mmio leak, and with patch 2 alone KASAN reports the double free. With both patches, no reports. spi-avmm and sch56xx were not run. Developed with Claude (Anthropic), which wrote the code and the commit messages. I reviewed every change. --- Arun Iyengar (2): regmap: Don't free the bus context when devm init fails regmap: mmio: Free the context if regmap init fails drivers/base/regmap/regmap-mmio.c | 18 ++++++++++++++---- drivers/base/regmap/regmap.c | 20 ++++++++++++-------- 2 files changed, 26 insertions(+), 12 deletions(-) --- base-commit: 222b61e9c570dac6c7a786d039e4c226624b426d change-id: 20261129-regmap-devm-ctx-2955bb2c1077 Best regards, -- Arun Iyengar