Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964862AbbLHKYY (ORCPT ); Tue, 8 Dec 2015 05:24:24 -0500 Received: from mail-am1on0139.outbound.protection.outlook.com ([157.56.112.139]:27136 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964812AbbLHKYU convert rfc822-to-8bit (ORCPT ); Tue, 8 Dec 2015 05:24:20 -0500 From: "Shah, Yash (Y.)" To: "dledford@redhat.com" , "sean.hefty@intel.com" , "hal.rosenstock@gmail.com" , "gregkh@linuxfoundation.org" , "a.hajda@samsung.com" , "ogerlitz@mellanox.com" , "matanb@mellanox.com" , "ira.weiny@intel.com" , "cse.anjalimenon@gmail.com" , "yun.wang@profitbricks.com" , "roland@purestorage.com" , "haggaie@mellanox.com" CC: "linux-rdma@vger.kernel.org" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] Staging: rdma:Delete unnecessary NULL check before calling function "kmem_cache_destroy" Thread-Topic: [PATCH] Staging: rdma:Delete unnecessary NULL check before calling function "kmem_cache_destroy" Thread-Index: AQHRMaKXRiyFAe/K8kuriLqz1J3uLQ== Date: Tue, 8 Dec 2015 10:24:17 +0000 Message-ID: <20151208102404.GA26085@ubuntu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yshah1@visteon.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [91.212.132.115] x-microsoft-exchange-diagnostics: 1;DBXPR06MB495;5:beQ5EXppvkLh73Zqz9nABPKssxv+SjC9wJzW1fqdE8VkpwzGbVRrnF0Oyv9TWiUtYh+BFqWqRixCHi0MPjRS1/VoboHtKX93yD7Z7FZBSVG5p6BVqmy9l/cVqwU2NCYO21kCfsO9/PM1Ft94SMXLtw==;24:kfDhOX9hTqqyf7Dco1xEfCOm4bOyIRA3bO5eKiQmWxPhZWkUIZ5xFIx9laMZh0ot8iM8U/5tH67AQ91vbyGla0orfMZzs0vkLZkWMij1ujU= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DBXPR06MB495; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(208512329853888); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046);SRVR:DBXPR06MB495;BCL:0;PCL:0;RULEID:;SRVR:DBXPR06MB495; x-forefront-prvs: 0784C803FD x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(5002640100001)(229853001)(122556002)(586003)(19580395003)(66066001)(19580405001)(33716001)(105586002)(40100003)(106356001)(50986999)(2501003)(92566002)(106116001)(54356999)(97736004)(5001960100002)(2201001)(1076002)(6116002)(102836003)(86362001)(3846002)(1096002)(1220700001)(87936001)(10400500002)(189998001)(5001770100001)(2900100001)(101416001)(33656002)(81156007)(2860100001)(11100500001)(5008740100001)(77096005)(5004730100002)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:DBXPR06MB495;H:DBXPR06MB494.eurprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <32E3FDD54F6152489982526F4B7E97B1@eurprd06.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Dec 2015 10:24:17.4771 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR06MB495 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3402 Lines: 104 From: Yash Shah The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the NULL check before calling this function is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Yash Shah --- drivers/staging/rdma/ehca/ehca_av.c | 3 +-- drivers/staging/rdma/ehca/ehca_cq.c | 3 +-- drivers/staging/rdma/ehca/ehca_main.c | 3 +-- drivers/staging/rdma/ehca/ehca_mrmw.c | 6 ++---- drivers/staging/rdma/ehca/ehca_pd.c | 3 +-- drivers/staging/rdma/ehca/ehca_qp.c | 3 +-- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rdma/ehca/ehca_av.c b/drivers/staging/rdma/ehca/ehca_av.c index fd7b6d0..94e088c 100644 --- a/drivers/staging/rdma/ehca/ehca_av.c +++ b/drivers/staging/rdma/ehca/ehca_av.c @@ -275,6 +275,5 @@ int ehca_init_av_cache(void) void ehca_cleanup_av_cache(void) { - if (av_cache) - kmem_cache_destroy(av_cache); + kmem_cache_destroy(av_cache); } diff --git a/drivers/staging/rdma/ehca/ehca_cq.c b/drivers/staging/rdma/ehca/ehca_cq.c index ea1b5c1..1aa7931 100644 --- a/drivers/staging/rdma/ehca/ehca_cq.c +++ b/drivers/staging/rdma/ehca/ehca_cq.c @@ -393,6 +393,5 @@ int ehca_init_cq_cache(void) void ehca_cleanup_cq_cache(void) { - if (cq_cache) - kmem_cache_destroy(cq_cache); + kmem_cache_destroy(cq_cache); } diff --git a/drivers/staging/rdma/ehca/ehca_main.c b/drivers/staging/rdma/ehca/ehca_main.c index 8246418..860b974 100644 --- a/drivers/staging/rdma/ehca/ehca_main.c +++ b/drivers/staging/rdma/ehca/ehca_main.c @@ -245,8 +245,7 @@ static void ehca_destroy_slab_caches(void) ehca_cleanup_cq_cache(); ehca_cleanup_pd_cache(); #ifdef CONFIG_PPC_64K_PAGES - if (ctblk_cache) - kmem_cache_destroy(ctblk_cache); + kmem_cache_destroy(ctblk_cache); #endif } diff --git a/drivers/staging/rdma/ehca/ehca_mrmw.c b/drivers/staging/rdma/ehca/ehca_mrmw.c index f914b30..553e883 100644 --- a/drivers/staging/rdma/ehca/ehca_mrmw.c +++ b/drivers/staging/rdma/ehca/ehca_mrmw.c @@ -2251,10 +2251,8 @@ int ehca_init_mrmw_cache(void) void ehca_cleanup_mrmw_cache(void) { - if (mr_cache) - kmem_cache_destroy(mr_cache); - if (mw_cache) - kmem_cache_destroy(mw_cache); + kmem_cache_destroy(mr_cache); + kmem_cache_destroy(mw_cache); } static inline int ehca_init_top_bmap(struct ehca_top_bmap *ehca_top_bmap, diff --git a/drivers/staging/rdma/ehca/ehca_pd.c b/drivers/staging/rdma/ehca/ehca_pd.c index 351577a..2a8aae4 100644 --- a/drivers/staging/rdma/ehca/ehca_pd.c +++ b/drivers/staging/rdma/ehca/ehca_pd.c @@ -119,6 +119,5 @@ int ehca_init_pd_cache(void) void ehca_cleanup_pd_cache(void) { - if (pd_cache) - kmem_cache_destroy(pd_cache); + kmem_cache_destroy(pd_cache); } diff --git a/drivers/staging/rdma/ehca/ehca_qp.c b/drivers/staging/rdma/ehca/ehca_qp.c index 2e89356..896c01f 100644 --- a/drivers/staging/rdma/ehca/ehca_qp.c +++ b/drivers/staging/rdma/ehca/ehca_qp.c @@ -2252,6 +2252,5 @@ int ehca_init_qp_cache(void) void ehca_cleanup_qp_cache(void) { - if (qp_cache) - kmem_cache_destroy(qp_cache); + kmem_cache_destroy(qp_cache); } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/