Skip to content

Commit

Permalink
USB: storage: karma: fix rio_karma_init return
Browse files Browse the repository at this point in the history
The function rio_karam_init() should return -ENOMEM instead of
value 0 (USB_STOR_TRANSPORT_GOOD) when allocation fails.

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

Fixes: dfe0d3b ("USB Storage: add rio karma eject support")
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Lin Ma <linma@zju.edu.cn>
Link: https://lore.kernel.org/r/20220412144359.28447-1-linma@zju.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
f0rm2l1n authored and gregkh committed Apr 21, 2022
1 parent 67ec2c7 commit b92ffb1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/usb/storage/karma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b92ffb1

Please sign in to comment.