From patchwork Mon May 23 07:13:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Danese X-Patchwork-Id: 9131231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B9FDF6075F for ; Mon, 23 May 2016 07:15:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B11C1280D2 for ; Mon, 23 May 2016 07:15:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A624B28206; Mon, 23 May 2016 07:15:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FF80280D2 for ; Mon, 23 May 2016 07:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753190AbcEWHPT (ORCPT ); Mon, 23 May 2016 03:15:19 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:35529 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753388AbcEWHPP (ORCPT ); Mon, 23 May 2016 03:15:15 -0400 Received: by mail-pf0-f179.google.com with SMTP id g64so9192174pfb.2 for ; Mon, 23 May 2016 00:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=VuBSY9Y/MbVJqma3CEEtM8jzJStQTvpeBjme1p7JUCc=; b=LSI/VN0RR7Ub3Xu81guaS+SWOqCMnAYNleojvvyLV9R4hAMeVdbEErO4aawWVPVuwt nOE13UnAYGmaOPrSlDn5MWDeouDvLd8EI6za0a1qu89xvlPLK6B6wpstORDeHOC1OzdI ZfGMHwZpQRX1op4lKUgy6g+b15r9zMumEZ8u2n/S+XEm1CghmQVUHeT4s+45eoq4Rliq VXg4AtXiYR7cRX5AyqdxNFLubuywGOfgvO4bA/Om7jaolCZZ1L5xJpb0n7ZbzH3Uhd6p mJffczSQb9lzSf29QemSLJCspIdy68dLbXTHP9F429fDJvdHBskftFswLpVi2Yf5/lw2 jvqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VuBSY9Y/MbVJqma3CEEtM8jzJStQTvpeBjme1p7JUCc=; b=A0WzBktIHNr88mgRnIKJ2WQxK+gzgSgr1orqLK7ez80qATwgxaaM83VKuOrODV733V fJUOFP+6Qi4T68cEeobdytW0AHoSX14GNmX25objOP2rW0Cn0Jy7EppxZ1xTereqAiRZ uYIn40tCRoSZHAGABnwerWyNZ+4Zp5eiaowoVPzWa2hoEupa9wf1r9FkJ/rNuIQBckjT oGG3MMK3dZ4TwjOSQn0YOe2NVAWhpoV1YfCb8U+f7QTwTjYMR/3zTB0W1QsERA+ZbI3e vvJ8HI5E5mgbjzsemOYCb3g/VpeVdLg3AkutZw1qOTR6OQi2V0+ewnwI0m7KtcRzshyl zVbg== X-Gm-Message-State: AOPr4FW+8Lgm9CT32TJLV4tBjWXSzyTVhU69UHO7BemRe52ipsWW0SOf1E1F+Mu3qoffYxvE X-Received: by 10.98.47.66 with SMTP id v63mr25089880pfv.67.1463987714733; Mon, 23 May 2016 00:15:14 -0700 (PDT) Received: from localhost.localdomain (c-67-169-180-20.hsd1.ca.comcast.net. [67.169.180.20]) by smtp.gmail.com with ESMTPSA id i75sm43918562pfj.51.2016.05.23.00.15.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 May 2016 00:15:13 -0700 (PDT) From: Mike Danese Cc: kernel-janitors@vger.kernel.org, Mike Danese , Jens Axboe , 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 Message-Id: <1463987633-125741-1-git-send-email-mikedanese@google.com> X-Mailer: git-send-email 2.5.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Jeff Moyer --- 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);