From patchwork Wed Dec 31 22:29:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1142 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220249; bh=myalJPx7jwblfAHH8qcBpx3Ds2EyqAnbHt6WUWEZ1c0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pECGUi2rgORMIfOYBDzJlDVEvsBRgbDV/UuwCM/2vOik3RrBOyi3VRn1P10w9rhV/ 2o8uh8ua05OIleWCkqyFOsKzsS54ZEO3BFrwuQBWZqfe7HYSIw2CccD/peqTYnh+Oj jy+m1ggeATCZrn9SqVuDfjSm6Xz4K51j2g4Ycb73/WTeLD9vIf47XsEi7WXc7+SqZ0 DKfA7Wh8zDTpF+qg+2p6GSaIfnlGqqj6HAcCtIgRepkPb5wqWFlNcHWJV072qCCOD6 DEZZU6IUxxgZx8h3gnrIedOsCyTrc+Zy1Yd/YetDmZoaDfFY0wKdB/0VcSdwTJrUMp G57MaAEJr9iEw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 44D1F68F65 for ; Wed, 31 Dec 2025 15:30:49 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Ldk2NBngW4xl for ; Wed, 31 Dec 2025 15:30:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220248; bh=myalJPx7jwblfAHH8qcBpx3Ds2EyqAnbHt6WUWEZ1c0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Ggqqq3k/SWe9sPVylA7KlV5Rm/36uwA3jLMqRY33qfxYfHPEfpsCoTjqlcSYJ+6xl QowdDUJB3AOv3iXV5ZlRvPifUYaA8VEO16bAr/OXcx23cF9vwst6cdW8oFcNGEPUTh i/KuQ3JsFY7qQHtLVY5rH7xje8HFsVhNon2n4zEQ18EEIMPV5MLGJz43rFtzV5/sR6 MYqci1CGAq9KDscrhDYUMrj5a0E+aZ7wHh4aMO6fYkj07+tI6SOU3ZXlDCMRSuFseX aP/jSZgIqnRJgNquA1pgz8Df6V2QdUycQVSE06Pd6gp0uuXqi5LAF+nyPyJ2fyk1VD x6pXcCfe1jcWQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3FD8368FCB for ; Wed, 31 Dec 2025 15:30:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220246; bh=i3n/ty9etcTby4mktSrRdtazZL+JjL3aq+4YjQtzh1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1hN7nFVbtKHU90v+RloZzhaorCYr6pMnaRN41HhCacxZw/CdFixpBSzhFuxtfXJg WY0wUTQVrQwAHNDzaF1X6yvuXvRWZyfiij4cp0iW4Uo/KGNEy4uFGb+OUmiuL6PQUF Wg/g85Q8q6Blw0Qyigpt1+cYEuzqBcjS6/tLirTl6wXJcJt53Q7vKEIb0P/ISz0kWS gpbTpFDYJX9RSyfl7c2MKKkFGfy95urOFXji3e5K5T0gLxSU/sc73pBw0vNjNSe6DX CWdgQUpU2lCTTwz2xQtb22Lmh5rFJn3xr9+OAGvwRxq1qM2Q7TCrhhXaHNN5UOI36e U9QesR0a6jBTw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1563268FC2; Wed, 31 Dec 2025 15:30:46 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id gRMDZzz461tA; Wed, 31 Dec 2025 15:30:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220245; bh=X7RoNpkuX1l33/44F2sRKYxQWkQNerN/t60bqYvl7SY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K2+i/w2LT9ulmuEyk3GNUqRgWTgiVoU6kW6Gz+tZfbSsBJ5KD2t69Sjvp4rjmU/Gr 99N1ychwfVe7LnCR2pdg21vtsp6pzZj0cJZljwcJ7V5SrfjAa3Wrak/guqnMIZRRf3 CGdIXxE7CaAyFsnz4lA1TQiSesj1dz2ihWGg0CuMaqvNuQ+IZBNqsLGWCJebaxI5bp 3xHQC5MytVUmO5ykjVUKkqdjZ8FtYmhjBRlujJnog+c6wGwWiHysv7uYqP8Mxpswlq f85BG7lh7anGS0WlGPbptVH1+KqrwCySxG438hlqjnkZxeRLUwvwTqh27YxRdfrT1C IiCSKrs0uPcUA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6F06568C5D; Wed, 31 Dec 2025 15:30:45 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 31 Dec 2025 15:29:37 -0700 Message-ID: <20251231223008.3251711-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251231223008.3251711-1-sjg@u-boot.org> References: <20251231223008.3251711-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: P6FA7Q2Z2XBGTTEA5RV3S4HS6AIUBGBJ X-Message-ID-Hash: P6FA7Q2Z2XBGTTEA5RV3S4HS6AIUBGBJ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/26] blkmap: Handle read-only slices in write path List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Some blkmap slices (like blkmap_crypt) don't support writes and have their write function set to NULL. The blkmap_blk_write_slice() function calls the write function without checking if it's NULL, causing a crash when attempting to write to such slices. Add a NULL check before calling the write function. When the slice doesn't support writes, return 0 to indicate no blocks were written. Co-developed-by: Claude Signed-off-by: Simon Glass --- drivers/block/blkmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c index 14aa1e4d088..bd55bdf24b7 100644 --- a/drivers/block/blkmap.c +++ b/drivers/block/blkmap.c @@ -281,6 +281,9 @@ static ulong blkmap_blk_write_slice(struct blkmap *bm, struct blkmap_slice *bms, { lbaint_t nr, cnt; + if (!bms->write) + return 0; + nr = blknr - bms->blknr; cnt = (blkcnt < bms->blkcnt) ? blkcnt : bms->blkcnt; return bms->write(bm, bms, nr, cnt, buffer);