* [PATCH] scsi: virtio_scsi: remove unnecessary condition check
@ 2020-07-09 15:06 Xianting Tian
2020-07-09 15:25 ` Paolo Bonzini
2020-07-14 4:58 ` Martin K. Petersen
0 siblings, 2 replies; 5+ messages in thread
From: Xianting Tian @ 2020-07-09 15:06 UTC (permalink / raw)
To: mst, jasowang, pbonzini, stefanha, jejb, martin.petersen
Cc: virtualization, linux-scsi, linux-kernel
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;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: virtio_scsi: remove unnecessary condition check
2020-07-09 15:06 [PATCH] scsi: virtio_scsi: remove unnecessary condition check Xianting Tian
@ 2020-07-09 15:25 ` Paolo Bonzini
2020-07-14 4:58 ` Martin K. Petersen
1 sibling, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-07-09 15:25 UTC (permalink / raw)
To: Xianting Tian, mst, jasowang, stefanha, jejb, martin.petersen
Cc: virtualization, linux-scsi, linux-kernel
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: virtio_scsi: remove unnecessary condition check
2020-07-09 15:06 [PATCH] scsi: virtio_scsi: remove unnecessary condition check Xianting Tian
2020-07-09 15:25 ` Paolo Bonzini
@ 2020-07-14 4:58 ` Martin K. Petersen
1 sibling, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2020-07-14 4:58 UTC (permalink / raw)
To: mst, pbonzini, jasowang, Xianting Tian, jejb, stefanha
Cc: Martin K . Petersen, virtualization, linux-kernel, linux-scsi
On Thu, 9 Jul 2020 11:06:07 -0400, 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.
Applied to 5.9/scsi-queue, thanks!
[1/1] scsi: virtio_scsi: Remove unnecessary condition check
https://git.kernel.org/mkp/scsi/c/92e8d0323a51
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: virtio_scsi: remove unnecessary condition check
2020-07-09 14:46 Xianting Tian
@ 2020-07-09 15:26 ` Paolo Bonzini
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-07-09 15:26 UTC (permalink / raw)
To: Xianting Tian, mst, jasowang, stefanha, jejb, martin.petersen
Cc: virtualization, linux-scsi, linux-kernel
On 09/07/20 16:46, Xianting Tian wrote:
> kmem_cache_destroy can correctly handle null pointer parameter,
> so there is no need to check if the parameter is null before
> calling kmem_cache_destroy.
>
> Signed-off-by: Xianting Tian <xianting_tian@126.com>
> ---
> drivers/scsi/virtio_scsi.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index bfec84a..5bc288f 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -1007,10 +1007,8 @@ static int __init init(void)
> mempool_destroy(virtscsi_cmd_pool);
> virtscsi_cmd_pool = NULL;
> }
> - if (virtscsi_cmd_cache) {
> - kmem_cache_destroy(virtscsi_cmd_cache);
> - virtscsi_cmd_cache = NULL;
> - }
> + kmem_cache_destroy(virtscsi_cmd_cache);
> + virtscsi_cmd_cache = NULL;
> return ret;
> }
>
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] scsi: virtio_scsi: remove unnecessary condition check
@ 2020-07-09 14:46 Xianting Tian
2020-07-09 15:26 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Xianting Tian @ 2020-07-09 14:46 UTC (permalink / raw)
To: mst, jasowang, pbonzini, stefanha, jejb, martin.petersen
Cc: virtualization, linux-scsi, linux-kernel
kmem_cache_destroy can correctly handle null pointer parameter,
so there is no need to check if the parameter is null before
calling kmem_cache_destroy.
Signed-off-by: Xianting Tian <xianting_tian@126.com>
---
drivers/scsi/virtio_scsi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index bfec84a..5bc288f 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -1007,10 +1007,8 @@ static int __init init(void)
mempool_destroy(virtscsi_cmd_pool);
virtscsi_cmd_pool = NULL;
}
- if (virtscsi_cmd_cache) {
- kmem_cache_destroy(virtscsi_cmd_cache);
- virtscsi_cmd_cache = NULL;
- }
+ kmem_cache_destroy(virtscsi_cmd_cache);
+ virtscsi_cmd_cache = NULL;
return ret;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-14 4:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 15:06 [PATCH] scsi: virtio_scsi: remove unnecessary condition check Xianting Tian
2020-07-09 15:25 ` Paolo Bonzini
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
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).