mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Danese <mikedanese@google.com>
To: unlisted-recipients:; (no To-header on input)
Cc: kernel-janitors@vger.kernel.org,
	Mike Danese <mikedanese@google.com>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org (open list:BLOCK LAYER),
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] blk: remove NULL check before freeing functions
Date: Mon, 23 May 2016 00:13:53 -0700	[thread overview]
Message-ID: <1463987633-125741-1-git-send-email-mikedanese@google.com> (raw)

Coccinelle complains:

WARNING: NULL check before freeing functions like kfree, debugfs_remove,
debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider
reorganizing relevant code to avoid passing NULL values.

Signed-off-by: Mike Danese <mikedanese@google.com>
---
 block/bio-integrity.c | 7 ++-----
 block/bio.c           | 7 ++-----
 block/blk-core.c      | 3 +--
 block/elevator.c      | 3 +--
 4 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 711e4d8d..27bf4e7 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -499,11 +499,8 @@ EXPORT_SYMBOL(bioset_integrity_create);
 
 void bioset_integrity_free(struct bio_set *bs)
 {
-	if (bs->bio_integrity_pool)
-		mempool_destroy(bs->bio_integrity_pool);
-
-	if (bs->bvec_integrity_pool)
-		mempool_destroy(bs->bvec_integrity_pool);
+	mempool_destroy(bs->bio_integrity_pool);
+	mempool_destroy(bs->bvec_integrity_pool);
 }
 EXPORT_SYMBOL(bioset_integrity_free);
 
diff --git a/block/bio.c b/block/bio.c
index 0e4aa42..e1e1773 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1844,11 +1844,8 @@ void bioset_free(struct bio_set *bs)
 	if (bs->rescue_workqueue)
 		destroy_workqueue(bs->rescue_workqueue);
 
-	if (bs->bio_pool)
-		mempool_destroy(bs->bio_pool);
-
-	if (bs->bvec_pool)
-		mempool_destroy(bs->bvec_pool);
+	mempool_destroy(bs->bio_pool);
+	mempool_destroy(bs->bvec_pool);
 
 	bioset_integrity_free(bs);
 	bio_put_slab(bs);
diff --git a/block/blk-core.c b/block/blk-core.c
index 2475b1c7..916e7c3 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -636,8 +636,7 @@ int blk_init_rl(struct request_list *rl, struct request_queue *q,
 
 void blk_exit_rl(struct request_list *rl)
 {
-	if (rl->rq_pool)
-		mempool_destroy(rl->rq_pool);
+	mempool_destroy(rl->rq_pool);
 }
 
 struct request_queue *blk_alloc_queue(gfp_t gfp_mask)
diff --git a/block/elevator.c b/block/elevator.c
index c3555c9..5dc91ca 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -847,8 +847,7 @@ int elv_register(struct elevator_type *e)
 	spin_lock(&elv_list_lock);
 	if (elevator_find(e->elevator_name)) {
 		spin_unlock(&elv_list_lock);
-		if (e->icq_cache)
-			kmem_cache_destroy(e->icq_cache);
+		kmem_cache_destroy(e->icq_cache);
 		return -EBUSY;
 	}
 	list_add_tail(&e->list, &elv_list);
-- 
2.5.0

             reply	other threads:[~2016-05-23  7:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23  7:13 Mike Danese [this message]
2016-05-23 15:20 ` Jeff Moyer

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=1463987633-125741-1-git-send-email-mikedanese@google.com \
    --to=mikedanese@google.com \
    --cc=axboe@kernel.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 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®