* [PATCH] block: Fix elevator_get_default() to check for null q->tag_set
@ 2024-10-04 12:39 SurajSonawane2415
2024-10-07 5:53 ` Christoph Hellwig
2024-10-07 11:14 ` [PATCH V2] " SurajSonawane2415
0 siblings, 2 replies; 5+ messages in thread
From: SurajSonawane2415 @ 2024-10-04 12:39 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, SurajSonawane2415
Fix null pointer error by checking if q->tag_set is null.
Address "block/elevator.c:569 elevator_get_default() error:
we previously assumed 'q->tag_set' could be null (see line 565)"
This change prevents errors by making sure q->tag_set is valid
before accessing its flags.
Signed-off-by: SurajSonawane2415 <surajsonawane0215@gmail.com>
---
block/elevator.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index 4122026b1..9ca32a6bd 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -562,12 +562,14 @@ static inline bool elv_support_iosched(struct request_queue *q)
*/
static struct elevator_type *elevator_get_default(struct request_queue *q)
{
- if (q->tag_set && q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT)
- return NULL;
+ if (q->tag_set) {
+ if (q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT)
+ return NULL;
- if (q->nr_hw_queues != 1 &&
- !blk_mq_is_shared_tags(q->tag_set->flags))
- return NULL;
+ if (q->nr_hw_queues != 1 &&
+ !blk_mq_is_shared_tags(q->tag_set->flags))
+ return NULL;
+ }
return elevator_find_get(q, "mq-deadline");
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] block: Fix elevator_get_default() to check for null q->tag_set
2024-10-04 12:39 [PATCH] block: Fix elevator_get_default() to check for null q->tag_set SurajSonawane2415
@ 2024-10-07 5:53 ` Christoph Hellwig
2024-10-07 11:14 ` [PATCH V2] " SurajSonawane2415
1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2024-10-07 5:53 UTC (permalink / raw)
To: SurajSonawane2415; +Cc: axboe, linux-block, linux-kernel
> static struct elevator_type *elevator_get_default(struct request_queue *q)
> {
> - if (q->tag_set && q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT)
> - return NULL;
> + if (q->tag_set) {
q->tag_set can't be NULL for a blk-mq queue. So you can just remove
the q->tag_set check here and also in elv_support_iosched.
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH V2] block: Fix elevator_get_default() to check for null q->tag_set
2024-10-04 12:39 [PATCH] block: Fix elevator_get_default() to check for null q->tag_set SurajSonawane2415
2024-10-07 5:53 ` Christoph Hellwig
@ 2024-10-07 11:14 ` SurajSonawane2415
2024-10-07 20:24 ` Jens Axboe
2024-10-07 20:26 ` Jens Axboe
1 sibling, 2 replies; 5+ messages in thread
From: SurajSonawane2415 @ 2024-10-07 11:14 UTC (permalink / raw)
To: surajsonawane0215, axboe; +Cc: linux-block, linux-kernel, hch
Fix error "block/elevator.c:569 elevator_get_default() error:
we previously assumed 'q->tag_set' could be null (see line 565)".
Since 'q->tag_set' cannot be NULL for blk-mq queues,
remove the unnecessary check in both `elevator_get_default`
and `elv_support_iosched`. This simplifies the logic and
ensures correct assumptions about 'q->tag_set' in blk-mq queues.
Signed-off-by: SurajSonawane2415 <surajsonawane0215@gmail.com>
---
V1 -> V2:
- Remove unnecessary `q->tag_set` check in `elv_support_iosched` function.
- Remove `q->tag_set` check because blk-mq queues always have a valid tag set.
block/elevator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index 4122026b1..60497e3b2 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -551,7 +551,7 @@ EXPORT_SYMBOL_GPL(elv_unregister);
static inline bool elv_support_iosched(struct request_queue *q)
{
if (!queue_is_mq(q) ||
- (q->tag_set && (q->tag_set->flags & BLK_MQ_F_NO_SCHED)))
+ (q->tag_set->flags & BLK_MQ_F_NO_SCHED))
return false;
return true;
}
@@ -562,7 +562,7 @@ static inline bool elv_support_iosched(struct request_queue *q)
*/
static struct elevator_type *elevator_get_default(struct request_queue *q)
{
- if (q->tag_set && q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT)
+ if (q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT)
return NULL;
if (q->nr_hw_queues != 1 &&
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH V2] block: Fix elevator_get_default() to check for null q->tag_set
2024-10-07 11:14 ` [PATCH V2] " SurajSonawane2415
@ 2024-10-07 20:24 ` Jens Axboe
2024-10-07 20:26 ` Jens Axboe
1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2024-10-07 20:24 UTC (permalink / raw)
To: SurajSonawane2415; +Cc: linux-block, linux-kernel, hch
On 10/7/24 5:14 AM, SurajSonawane2415 wrote:
> Fix error "block/elevator.c:569 elevator_get_default() error:
> we previously assumed 'q->tag_set' could be null (see line 565)".
> Since 'q->tag_set' cannot be NULL for blk-mq queues,
> remove the unnecessary check in both `elevator_get_default`
> and `elv_support_iosched`. This simplifies the logic and
> ensures correct assumptions about 'q->tag_set' in blk-mq queues.
For future patches:
1) Wrap at 72 characters, your commit message is using shorter line
lengths.
2) Don't both with file numbers, they change all of the time. Digging
out an old commit with line numbers isn't very useful, you'd have to
rewind your tree for them to make sense.
I'll commit this, but rewrite the commit message somewhat.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] block: Fix elevator_get_default() to check for null q->tag_set
2024-10-07 11:14 ` [PATCH V2] " SurajSonawane2415
2024-10-07 20:24 ` Jens Axboe
@ 2024-10-07 20:26 ` Jens Axboe
1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2024-10-07 20:26 UTC (permalink / raw)
To: SurajSonawane2415; +Cc: linux-block, linux-kernel, hch
On Mon, 07 Oct 2024 16:44:16 +0530, SurajSonawane2415 wrote:
> Fix error "block/elevator.c:569 elevator_get_default() error:
> we previously assumed 'q->tag_set' could be null (see line 565)".
> Since 'q->tag_set' cannot be NULL for blk-mq queues,
> remove the unnecessary check in both `elevator_get_default`
> and `elv_support_iosched`. This simplifies the logic and
> ensures correct assumptions about 'q->tag_set' in blk-mq queues.
>
> [...]
Applied, thanks!
[1/1] block: Fix elevator_get_default() to check for null q->tag_set
commit: b402328a24ee7193a8ab84277c0c90ae16768126
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-07 20:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-04 12:39 [PATCH] block: Fix elevator_get_default() to check for null q->tag_set SurajSonawane2415
2024-10-07 5:53 ` Christoph Hellwig
2024-10-07 11:14 ` [PATCH V2] " SurajSonawane2415
2024-10-07 20:24 ` Jens Axboe
2024-10-07 20:26 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox