Message ID | 1463987633-125741-1-git-send-email-mikedanese@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Mike Danese <mikedanese@google.com> writes: > 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> Acked-by: Jeff Moyer <jmoyer@redhat.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); -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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);
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(-)