All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch -next] blk-mq: NULL dereference in __blk_mq_alloc_rq_maps()
@ 2014-09-13  8:09 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2014-09-13  8:09 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-kernel, kernel-janitors, Elliott, Robert (Server Storage)

We shouldn't set "set->tags" to NULL here because if we return -ENOMEM
here then we call the function a second time.  On the second time
through the loop then the statement:

	set->tags[i] = blk_mq_init_rq_map(set, i);

will Oops.  Also it is a memory leak and a layering violation.  There is
a correct call to kfree(set->tags) in blk_mq_alloc_tag_set().

Fixes: a516440542af ('blk-mq: scale depth and rq map appropriate if low on memory')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 3d863df..7e7ca57 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1961,7 +1961,6 @@ out_unwind:
 	while (--i >= 0)
 		blk_mq_free_rq_map(set, set->tags[i], i);
 
-	set->tags = NULL;
 	return -ENOMEM;
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [patch -next] blk-mq: NULL dereference in __blk_mq_alloc_rq_maps()
@ 2014-09-13  8:09 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2014-09-13  8:09 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-kernel, kernel-janitors, Elliott, Robert (Server Storage)

We shouldn't set "set->tags" to NULL here because if we return -ENOMEM
here then we call the function a second time.  On the second time
through the loop then the statement:

	set->tags[i] = blk_mq_init_rq_map(set, i);

will Oops.  Also it is a memory leak and a layering violation.  There is
a correct call to kfree(set->tags) in blk_mq_alloc_tag_set().

Fixes: a516440542af ('blk-mq: scale depth and rq map appropriate if low on memory')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 3d863df..7e7ca57 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1961,7 +1961,6 @@ out_unwind:
 	while (--i >= 0)
 		blk_mq_free_rq_map(set, set->tags[i], i);
 
-	set->tags = NULL;
 	return -ENOMEM;
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-13  8:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-13  8:09 [patch -next] blk-mq: NULL dereference in __blk_mq_alloc_rq_maps() Dan Carpenter
2014-09-13  8:09 ` Dan Carpenter

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.