All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] USB: storage: karma: fix rio_karma_init return
@ 2022-04-11  6:02 Lin Ma
  2022-04-11 14:27 ` Alan Stern
  2022-04-12 14:21 ` Alan Stern
  0 siblings, 2 replies; 5+ messages in thread
From: Lin Ma @ 2022-04-11  6:02 UTC (permalink / raw)
  To: stern, gregkh, linux-usb, usb-storage, mdharm-usb; +Cc: Lin Ma, stable

The function rio_karam_init() should return -ENOMEM instead of
value 0 (USB_STOR_TRANSPORT_GOOD) when allocation fails.

Simlarlly, it should return -EIO when rio_karma_send_command() fails.

Cc: stable@vger.kernel.org
Fixes: dfe0d3ba20e8 ("USB Storage: add rio karma eject support")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
 drivers/usb/storage/karma.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index 05cec81dcd3f..38ddfedef629 100644
--- a/drivers/usb/storage/karma.c
+++ b/drivers/usb/storage/karma.c
@@ -174,24 +174,25 @@ static void rio_karma_destructor(void *extra)
 
 static int rio_karma_init(struct us_data *us)
 {
-	int ret = 0;
 	struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
 
 	if (!data)
-		goto out;
+		return -ENOMEM;
 
 	data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO);
 	if (!data->recv) {
 		kfree(data);
-		goto out;
+		return -ENOMEM;
 	}
 
 	us->extra = data;
 	us->extra_destructor = rio_karma_destructor;
-	ret = rio_karma_send_command(RIO_ENTER_STORAGE, us);
-	data->in_storage = (ret == 0);
-out:
-	return ret;
+	if (rio_karma_send_command(RIO_ENTER_STORAGE, us))
+		return -EIO;
+
+	data->in_storage = 1;
+
+	return 0;
 }
 
 static struct scsi_host_template karma_host_template;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] USB: storage: karma: fix rio_karma_init return
  2022-04-11  6:02 [PATCH v2] USB: storage: karma: fix rio_karma_init return Lin Ma
@ 2022-04-11 14:27 ` Alan Stern
  2022-04-12  2:14   ` Lin Ma
  2022-04-12 14:21 ` Alan Stern
  1 sibling, 1 reply; 5+ messages in thread
From: Alan Stern @ 2022-04-11 14:27 UTC (permalink / raw)
  To: Lin Ma; +Cc: gregkh, linux-usb, usb-storage, mdharm-usb, stable

On Mon, Apr 11, 2022 at 02:02:46PM +0800, Lin Ma wrote:
> The function rio_karam_init() should return -ENOMEM instead of
> value 0 (USB_STOR_TRANSPORT_GOOD) when allocation fails.
> 
> Simlarlly, it should return -EIO when rio_karma_send_command() fails.
> 
> Cc: stable@vger.kernel.org
> Fixes: dfe0d3ba20e8 ("USB Storage: add rio karma eject support")
> Signed-off-by: Lin Ma <linma@zju.edu.cn>
> ---

Acked-by: Alan Stern <stern@rowland.harvard.edu>

>  drivers/usb/storage/karma.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
> index 05cec81dcd3f..38ddfedef629 100644
> --- a/drivers/usb/storage/karma.c
> +++ b/drivers/usb/storage/karma.c
> @@ -174,24 +174,25 @@ static void rio_karma_destructor(void *extra)
>  
>  static int rio_karma_init(struct us_data *us)
>  {
> -	int ret = 0;
>  	struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
>  
>  	if (!data)
> -		goto out;
> +		return -ENOMEM;
>  
>  	data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO);
>  	if (!data->recv) {
>  		kfree(data);
> -		goto out;
> +		return -ENOMEM;
>  	}
>  
>  	us->extra = data;
>  	us->extra_destructor = rio_karma_destructor;
> -	ret = rio_karma_send_command(RIO_ENTER_STORAGE, us);
> -	data->in_storage = (ret == 0);
> -out:
> -	return ret;
> +	if (rio_karma_send_command(RIO_ENTER_STORAGE, us))
> +		return -EIO;
> +
> +	data->in_storage = 1;
> +
> +	return 0;
>  }
>  
>  static struct scsi_host_template karma_host_template;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] USB: storage: karma: fix rio_karma_init return
  2022-04-11 14:27 ` Alan Stern
@ 2022-04-12  2:14   ` Lin Ma
  0 siblings, 0 replies; 5+ messages in thread
From: Lin Ma @ 2022-04-12  2:14 UTC (permalink / raw)
  To: Alan Stern; +Cc: gregkh, linux-usb, usb-storage, mdharm-usb, stable

Hello Alan

> 
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
> 

Gotcha, sorry again for the inconvenience.
The new one: https://marc.info/?l=linux-usb&m=164972959907049&w=2

Regards
Lin Ma

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] USB: storage: karma: fix rio_karma_init return
  2022-04-11  6:02 [PATCH v2] USB: storage: karma: fix rio_karma_init return Lin Ma
  2022-04-11 14:27 ` Alan Stern
@ 2022-04-12 14:21 ` Alan Stern
  2022-04-12 14:47   ` Lin Ma
  1 sibling, 1 reply; 5+ messages in thread
From: Alan Stern @ 2022-04-12 14:21 UTC (permalink / raw)
  To: Lin Ma; +Cc: gregkh, linux-usb, usb-storage, mdharm-usb, stable

On Mon, Apr 11, 2022 at 02:02:46PM +0800, Lin Ma wrote:
> The function rio_karam_init() should return -ENOMEM instead of
> value 0 (USB_STOR_TRANSPORT_GOOD) when allocation fails.
> 
> Simlarlly, it should return -EIO when rio_karma_send_command() fails.

s/Simlarlly/Similarly/

> 
> Cc: stable@vger.kernel.org
> Fixes: dfe0d3ba20e8 ("USB Storage: add rio karma eject support")
> Signed-off-by: Lin Ma <linma@zju.edu.cn>
> ---

At this point (just after the "---" line) you should have a description 
of how this patch version differs from the previous version.  Otherwise 
we don't know what has changed and what to look for.

Alan Stern

>  drivers/usb/storage/karma.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
> index 05cec81dcd3f..38ddfedef629 100644
> --- a/drivers/usb/storage/karma.c
> +++ b/drivers/usb/storage/karma.c
> @@ -174,24 +174,25 @@ static void rio_karma_destructor(void *extra)
>  
>  static int rio_karma_init(struct us_data *us)
>  {
> -	int ret = 0;
>  	struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
>  
>  	if (!data)
> -		goto out;
> +		return -ENOMEM;
>  
>  	data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO);
>  	if (!data->recv) {
>  		kfree(data);
> -		goto out;
> +		return -ENOMEM;
>  	}
>  
>  	us->extra = data;
>  	us->extra_destructor = rio_karma_destructor;
> -	ret = rio_karma_send_command(RIO_ENTER_STORAGE, us);
> -	data->in_storage = (ret == 0);
> -out:
> -	return ret;
> +	if (rio_karma_send_command(RIO_ENTER_STORAGE, us))
> +		return -EIO;
> +
> +	data->in_storage = 1;
> +
> +	return 0;
>  }
>  
>  static struct scsi_host_template karma_host_template;
> -- 
> 2.35.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] USB: storage: karma: fix rio_karma_init return
  2022-04-12 14:21 ` Alan Stern
@ 2022-04-12 14:47   ` Lin Ma
  0 siblings, 0 replies; 5+ messages in thread
From: Lin Ma @ 2022-04-12 14:47 UTC (permalink / raw)
  To: Alan Stern; +Cc: gregkh, linux-usb, usb-storage, mdharm-usb, stable

Hello Alan,

Jesus Christ, I promised next time I will use grammar tools to avoid waste maintainer's time for the typo like this.

> s/Simlarlly/Similarly/
> 


> 
> At this point (just after the "---" line) you should have a description 
> of how this patch version differs from the previous version.  Otherwise 
> we don't know what has changed and what to look for.

Gotcha, the new version at https://marc.info/?l=linux-usb&m=164977462632545&w=2

Thanks again for the patient and useful reply. :)

Regards
Lin Ma

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-12 14:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11  6:02 [PATCH v2] USB: storage: karma: fix rio_karma_init return Lin Ma
2022-04-11 14:27 ` Alan Stern
2022-04-12  2:14   ` Lin Ma
2022-04-12 14:21 ` Alan Stern
2022-04-12 14:47   ` Lin Ma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.