From: Paolo Bonzini <pbonzini@redhat.com>
To: Xianting Tian <xianting_tian@126.com>,
mst@redhat.com, jasowang@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: Re: [PATCH] scsi: virtio_scsi: remove unnecessary condition check
Date: Thu, 9 Jul 2020 17:25:23 +0200 [thread overview]
Message-ID: <d7a9319b-37ec-95dd-c20c-76017a3b1699@redhat.com> (raw)
In-Reply-To: <1594307167-8807-1-git-send-email-xianting_tian@126.com>
On 09/07/20 17:06, Xianting Tian wrote:
> 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 <xianting_tian@126.com>
> ---
> 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;
> }
>
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2020-07-09 15:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 15:06 [PATCH] scsi: virtio_scsi: remove unnecessary condition check Xianting Tian
2020-07-09 15:25 ` Paolo Bonzini [this message]
2020-07-14 4:58 ` Martin K. Petersen
-- strict thread matches above, loose matches on Subject: below --
2020-07-09 14:46 Xianting Tian
2020-07-09 15:26 ` Paolo Bonzini
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=d7a9319b-37ec-95dd-c20c-76017a3b1699@redhat.com \
--to=pbonzini@redhat.com \
--cc=jasowang@redhat.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mst@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xianting_tian@126.com \
/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;
as well as URLs for NNTP newsgroup(s).