From patchwork Fri Jan 2 00:50:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1171 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=1767315111; bh=mlMOPvry7AdjUkvYqU8Hhzy35DW4nXFkjP62BMurm8E=; 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=NwCUeWMIcEb1LHB5bSErI3/0C/MpZ7uNqpPhH+kTjmGOh2AtDSLRCUQ90CSgWCxMf dVtPEhuemHGwmAbp3f8eJK03iu3Fy7ZBiVkN+P1XiaSm83r3C79jBjtdZWt9sYJ6VL gwa6n4P/IY6gbPt438X3ttlxVqoiOz2RuPXOdHl+7x4IRDtaFzLOx13Yn4pogsmHEw 2ncbtPyxto0cT4o60KZCt8zOBsMTBodOhasve0OOqW8qt0VKvk2dbjuxoebGjmfh7p wpJYikPKfkqqqOCgjJ4lTkkP0q/vs8N8jW9ZKYqnEHT9lreruErcT/iHev1lij2sil t1YAZt2eWIpfw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F9E269007 for ; Thu, 1 Jan 2026 17:51:51 -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 k9QFKMnP0_Sx for ; Thu, 1 Jan 2026 17:51:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315111; bh=mlMOPvry7AdjUkvYqU8Hhzy35DW4nXFkjP62BMurm8E=; 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=NwCUeWMIcEb1LHB5bSErI3/0C/MpZ7uNqpPhH+kTjmGOh2AtDSLRCUQ90CSgWCxMf dVtPEhuemHGwmAbp3f8eJK03iu3Fy7ZBiVkN+P1XiaSm83r3C79jBjtdZWt9sYJ6VL gwa6n4P/IY6gbPt438X3ttlxVqoiOz2RuPXOdHl+7x4IRDtaFzLOx13Yn4pogsmHEw 2ncbtPyxto0cT4o60KZCt8zOBsMTBodOhasve0OOqW8qt0VKvk2dbjuxoebGjmfh7p wpJYikPKfkqqqOCgjJ4lTkkP0q/vs8N8jW9ZKYqnEHT9lreruErcT/iHev1lij2sil t1YAZt2eWIpfw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F3EA68FFD for ; Thu, 1 Jan 2026 17:51:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315109; bh=IdPD5nLrcij4Y6j6YaKudJJC2o3GJgSb1CvpMVgyaBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q379F4LC4oYHPHePAdoxMhFQLbDFIX6cdSJrxeQ/am9O4Yne7RlKQEMyZxLheJ7As 56GfGIafUzTI5FLDcmoEEZpuNklZsy+JAVNF/UeZqUHazxjWR+5sJEzODzNw+Dytti qU7i49i2Hyuva+coTBJHNqhzklYie6NZvF64J0RYm7sBhhcUDkH8zx4TllyLs76HoI x4jzD8qCt0gEnjAijZsAlPNqkJ3/lmps0gAQeaVQJfA0I1I3SAAuKiQDGEUGODWYBW 1ahc1VPvCrVKEPrQBwk0+ESpUokvxniWkZ2wJBXRWz3VGhan2EROM46ssVY2U32GG7 4nc78oP3Q/kNQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5371A68F56; Thu, 1 Jan 2026 17:51: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 10026) with ESMTP id vlg6YhAiCLpd; Thu, 1 Jan 2026 17:51:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315105; bh=KFbXeYBGmqawrlCAVCobEGoHa2a2U0nIV2zLvzkBs5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJHLdwgfuu220m5mx/6qn/Wayg8qaAPc1lAFTENr6sF0E40HZcjBfbu3td6p8/oir SFpBb2Rs39aSVLQ9UCXC2/uoMtEyRZy5bJCM0NUWCEC7Lf5iJaq2Ac43X2NxGVvQPM lP4ObrQ+P3J2q5qXFO/FFeioVDPXLsfblsJm5Pnwr9mNaLq3kuV2bf6iOIQavU9gb0 rZsZuQ+WCQKo84CZCpnAn38FlY2HLTenr27rkktHnIQpaH6ZlT+c+6MRoPr0w6oaf8 2Qe1BDSlPCwDoLT/IARF8xXzHUaK85e25Dzq/Lqd53r89Pto7vOpJCoHbQyLd96QNH cJii5qZT9+HKQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B247E68313; Thu, 1 Jan 2026 17:51:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:37 -0700 Message-ID: <20260102005112.552256-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EQCB2C6KNCJ35LPM3XZJZIGBTANWM5RJ X-Message-ID-Hash: EQCB2C6KNCJ35LPM3XZJZIGBTANWM5RJ 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 v2 07/30] 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 --- (no changes since v1) 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);