* [PATCH] block: add NULL argument check to bioset_free()
@ 2017-10-02 7:06 Tobin C. Harding
0 siblings, 0 replies; only message in thread
From: Tobin C. Harding @ 2017-10-02 7:06 UTC (permalink / raw)
To: Jens Axboe; +Cc: Tobin C. Harding, linux-block, linux-kernel
Currently bioset_free() will oops if passed a NULL argument. Other
kernel 'free' functions typically check for NULL arguments and
return. The rule of least surprise dictates that bioset_free() should
behave safely even if passed a NULL argument.
Add NULL argument check to bioset_free().
Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
block/bio.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/bio.c b/block/bio.c
index b38e962..780aecc 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1925,6 +1925,9 @@ mempool_t *biovec_create_pool(int pool_entries)
void bioset_free(struct bio_set *bs)
{
+ if (unlikely(!bs))
+ return;
+
if (bs->rescue_workqueue)
destroy_workqueue(bs->rescue_workqueue);
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-10-02 7:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-02 7:06 [PATCH] block: add NULL argument check to bioset_free() Tobin C. Harding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®