Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1508739ybt; Thu, 9 Jul 2020 08:39:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs66NSQ4S1oCy8zxFnlQ9dL5efn0UZ8iEASGFS62SwtEsaU+EwSTUbOnXTRZa4mPNsqwd0 X-Received: by 2002:aa7:d802:: with SMTP id v2mr64706004edq.77.1594309182766; Thu, 09 Jul 2020 08:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594309182; cv=none; d=google.com; s=arc-20160816; b=zwbU8DMPZDJo7jbDgLKftnzp42KVd6KmiwH56y2skLSmqXqCGSGMfQCG78TQb1ViZG Ss/bi+wH4vmSnWARiMxgYY04Qz756jv9esSckQcvmOOYX0QmA8vwBYtcY8D8ViLO0iRE uFnll5+kg2E2Yi5bM0mGiue3ebkDe1y58wBWsgaaBXXIZQKavjHETsRd3jSPKYa0vES+ +G3eYsITJflPv4g2tK1MOmWbYS3dYpoDNAQ/iABrOt0OXIT8B7YLq4/YSGASqAyzimbo 2FfojUdA82yWHHD2IE8d/7cN9PmkW4RGe9OlYCt9KJLzB0WnlTgZNJi9drZ9mk0MYJOI iWhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=nlTBb/0mf2htxgi1qK4HyVVy5Vg0edIYoQo4K6WIOA0=; b=Pf/Z6D5hJO+HTw/+tA+BfMbTnnsUaKbgCXW/axguY4fkSVfAZ+Yw0EVD6K4MFYChyv yPl3e+Pb14qnMw1IzBRHo+xYBM6b3s5pFicl5GK3O5Q4b7CA0QLKfsR5FZnL3hLIvhOs 9SRHEWLsmQWjI2w/6hb6nQ5964oLCR0YMYPp/4Szg7ac9gFLt03sXKlC8Rc8XOXbxOQU HCHbJxdCQkga9uxfXTNgAQ5pXs33JamHnxgEP2bZO5Jqw2bMisPmETV/OgsfsuOeIR6D AV6UtwH7cqItaZw1lPhpXJHLYK9Ja1Aon1WVLoKtZGR8lCGVm2fSWTTFZy6mhgxEEQa+ vG8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=bVs7Sqtv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si2041195ejt.753.2020.07.09.08.38.57; Thu, 09 Jul 2020 08:39:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=bVs7Sqtv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728049AbgGIPhf (ORCPT + 99 others); Thu, 9 Jul 2020 11:37:35 -0400 Received: from m15112.mail.126.com ([220.181.15.112]:51555 "EHLO m15112.mail.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbgGIPhe (ORCPT ); Thu, 9 Jul 2020 11:37:34 -0400 X-Greylist: delayed 1828 seconds by postgrey-1.27 at vger.kernel.org; Thu, 09 Jul 2020 11:37:32 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=nlTBb/0mf2htxgi1qK 4HyVVy5Vg0edIYoQo4K6WIOA0=; b=bVs7SqtviqcojpZxxESbFENwtF0N5+Ab2a f7UmuS5NAj3foCnQHW+TZOQdgsPte6WhxvgmQXzD4jh90M1nOZ8tX2L3v+VQJKjS qsFvGYISU9nz65sEO9rGenPiNzwFqISZz/lIVc7MGfw9/P6aJ6oTJNvZGVBcjIWE I59Y9gkLo= Received: from 192.168.137.252 (unknown [112.10.74.133]) by smtp2 (Coremail) with SMTP id DMmowABX1SFfMgdfeNahFA--.52098S3; Thu, 09 Jul 2020 23:06:09 +0800 (CST) From: Xianting Tian To: mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: virtualization@lists.linux-foundation.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: virtio_scsi: remove unnecessary condition check Date: Thu, 9 Jul 2020 11:06:07 -0400 Message-Id: <1594307167-8807-1-git-send-email-xianting_tian@126.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DMmowABX1SFfMgdfeNahFA--.52098S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xw47tryktw1xZr18WrW8Xrb_yoWDWFc_XF 40qrsrGr15KFn2krWIkrWfArZ09anrZa1j9ryFgFWfCr1Yq3909r4jqryrZF1fWw1jk3W7 Cw40yryS9r13CjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8Tv3UUUUUU== X-Originating-IP: [112.10.74.133] X-CM-SenderInfo: h0ld03plqjs3xldqqiyswou0bp/1tbi5gtcpFpD+5LX2gABsp Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmem_cache_destroy and mempool_destroy can correctly handle null pointer parameter, so there is no need to check if the parameter is null before calling kmem_cache_destroy and mempool_destroy. Signed-off-by: Xianting Tian --- drivers/scsi/virtio_scsi.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index bfec84a..54ac83e 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -1003,14 +1003,10 @@ static int __init init(void) return 0; error: - if (virtscsi_cmd_pool) { - mempool_destroy(virtscsi_cmd_pool); - virtscsi_cmd_pool = NULL; - } - if (virtscsi_cmd_cache) { - kmem_cache_destroy(virtscsi_cmd_cache); - virtscsi_cmd_cache = NULL; - } + mempool_destroy(virtscsi_cmd_pool); + virtscsi_cmd_pool = NULL; + kmem_cache_destroy(virtscsi_cmd_cache); + virtscsi_cmd_cache = NULL; return ret; } -- 1.8.3.1