All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH 2/3] block: fix NULL pointer dereference in disk_report_zones()
Date: Thu, 13 Nov 2025 22:40:27 +0900	[thread overview]
Message-ID: <20251113134028.890166-3-dlemoal@kernel.org> (raw)
In-Reply-To: <20251113134028.890166-1-dlemoal@kernel.org>

Commit 2284eec5053d ("block: introduce blkdev_get_zone_info()")
introduced the report_active field in struct blk_report_zones_args so
that open and closed zones can be reported with the condition
BLK_ZONE_COND_ACTIVE in the case of a cached report zone.
However, the args pointer to a struct blk_report_zones_args that is
passed to disk_report_zones() can be NULL, e.g. in the case of internal
report zones operations for device mapper zoned targets.

Fix disk_report_zones() to make sure to check that the args is not null
before updating a zone condition for cached zone reports.

Fixes: 2284eec5053d ("block: introduce blkdev_get_zone_info()")
Reported-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 block/blk-zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 98c26af01e24..dcc295721c2c 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -854,7 +854,7 @@ static unsigned int disk_zone_wplug_sync_wp_offset(struct gendisk *disk,
 int disk_report_zone(struct gendisk *disk, struct blk_zone *zone,
 		     unsigned int idx, struct blk_report_zones_args *args)
 {
-	if (args->report_active) {
+	if (args && args->report_active) {
 		/*
 		 * If we come here, then this is a report zones as a fallback
 		 * for a cached report. So collapse the implicit open, explicit
-- 
2.51.1


  parent reply	other threads:[~2025-11-13 13:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 13:40 [PATCH 0/3] Fixes for zoned changes in block/for-next Damien Le Moal
2025-11-13 13:40 ` [PATCH 1/3] block: fix NULL pointer dereference in blk_zone_reset_all_bio_endio() Damien Le Moal
2025-11-13 14:44   ` Christoph Hellwig
2025-11-13 13:40 ` Damien Le Moal [this message]
2025-11-13 14:45   ` [PATCH 2/3] block: fix NULL pointer dereference in disk_report_zones() Christoph Hellwig
2025-11-13 13:40 ` [PATCH 3/3] dm: fix zone reset all operation processing Damien Le Moal
2025-11-13 14:46   ` Christoph Hellwig
2025-11-13 16:16 ` [PATCH 0/3] Fixes for zoned changes in block/for-next Jens Axboe

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=20251113134028.890166-3-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=shinichiro.kawasaki@wdc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.