[PATCH] block: add NULL argument check to bioset_free()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---

 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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux