2023-05-29 07:53:46

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] scsi: virtio_scsi: Remove a useless function call

'inq_result' is known to be NULL. There is no point calling kfree().

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/scsi/virtio_scsi.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 58498da9869a..bd5633667d01 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -338,10 +338,8 @@ static int virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
int result, inquiry_len, inq_result_len = 256;
char *inq_result = kmalloc(inq_result_len, GFP_KERNEL);

- if (!inq_result) {
- kfree(inq_result);
+ if (!inq_result)
return -ENOMEM;
- }

shost_for_each_device(sdev, shost) {
inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;
--
2.34.1



2023-05-29 14:31:09

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH] scsi: virtio_scsi: Remove a useless function call

On 5/29/23 09:35, Christophe JAILLET wrote:
> 'inq_result' is known to be NULL. There is no point calling kfree().
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/scsi/virtio_scsi.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 58498da9869a..bd5633667d01 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -338,10 +338,8 @@ static int virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
> int result, inquiry_len, inq_result_len = 256;
> char *inq_result = kmalloc(inq_result_len, GFP_KERNEL);
>
> - if (!inq_result) {
> - kfree(inq_result);
> + if (!inq_result)
> return -ENOMEM;
> - }
>
> shost_for_each_device(sdev, shost) {
> inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;

Reviewed-by: Paolo Bonzini <[email protected]>


2023-05-29 15:36:19

by Stefan Hajnoczi

[permalink] [raw]
Subject: Re: [PATCH] scsi: virtio_scsi: Remove a useless function call

On Mon, May 29, 2023 at 09:35:08AM +0200, Christophe JAILLET wrote:
> 'inq_result' is known to be NULL. There is no point calling kfree().
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/scsi/virtio_scsi.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)

Reviewed-by: Stefan Hajnoczi <[email protected]>


Attachments:
(No filename) (366.00 B)
signature.asc (499.00 B)
Download all attachments

2023-05-31 15:47:44

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH] scsi: virtio_scsi: Remove a useless function call


Christophe,

> 'inq_result' is known to be NULL. There is no point calling kfree().

Applied to 6.5/scsi-staging, thanks!

--
Martin K. Petersen Oracle Linux Engineering

2023-06-02 12:34:07

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH] scsi: virtio_scsi: Remove a useless function call

On Mon, May 29, 2023 at 09:35:08AM +0200, Christophe JAILLET wrote:
> 'inq_result' is known to be NULL. There is no point calling kfree().
>
> Signed-off-by: Christophe JAILLET <[email protected]>

Acked-by: Michael S. Tsirkin <[email protected]>

> ---
> drivers/scsi/virtio_scsi.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 58498da9869a..bd5633667d01 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -338,10 +338,8 @@ static int virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
> int result, inquiry_len, inq_result_len = 256;
> char *inq_result = kmalloc(inq_result_len, GFP_KERNEL);
>
> - if (!inq_result) {
> - kfree(inq_result);
> + if (!inq_result)
> return -ENOMEM;
> - }
>
> shost_for_each_device(sdev, shost) {
> inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;
> --
> 2.34.1


2023-06-08 01:45:25

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH] scsi: virtio_scsi: Remove a useless function call

On Mon, 29 May 2023 09:35:08 +0200, Christophe JAILLET wrote:

> 'inq_result' is known to be NULL. There is no point calling kfree().
>
>

Applied to 6.5/scsi-queue, thanks!

[1/1] scsi: virtio_scsi: Remove a useless function call
https://git.kernel.org/mkp/scsi/c/0e5e41ee3d73

--
Martin K. Petersen Oracle Linux Engineering