diff mbox series

[v2] usb: sierra: fix a missing check of device_create_file

Message ID 20190325030828.14068-1-kjlu@umn.edu (mailing list archive)
State Mainlined
Commit 1a137b47ce6bd4f4b14662d2f5ace913ea7ffbf8
Headers show
Series [v2] usb: sierra: fix a missing check of device_create_file | expand

Commit Message

Kangjie Lu March 25, 2019, 3:08 a.m. UTC
device_create_file() could fail and return an error code. The fix
captures the error and returns the error code upstream in case it
indeed failed.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/usb/storage/sierra_ms.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Alan Stern March 25, 2019, 2:15 p.m. UTC | #1
On Sun, 24 Mar 2019, Kangjie Lu wrote:

> device_create_file() could fail and return an error code. The fix
> captures the error and returns the error code upstream in case it
> indeed failed.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/usb/storage/sierra_ms.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c
> index 6ac60abd2e15..e605cbc3d8bf 100644
> --- a/drivers/usb/storage/sierra_ms.c
> +++ b/drivers/usb/storage/sierra_ms.c
> @@ -194,8 +194,6 @@ int sierra_ms_init(struct us_data *us)
>  		kfree(swocInfo);
>  	}
>  complete:
> -	result = device_create_file(&us->pusb_intf->dev, &dev_attr_truinst);
> -
> -	return 0;
> +	return device_create_file(&us->pusb_intf->dev, &dev_attr_truinst);
>  }

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

It's possible the original author intended the function to succeed even 
if device_create_file() failed, since the information in the file 
doesn't seem to be very important.  However, I will accept the patch.

Alan Stern
diff mbox series

Patch

diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c
index 6ac60abd2e15..e605cbc3d8bf 100644
--- a/drivers/usb/storage/sierra_ms.c
+++ b/drivers/usb/storage/sierra_ms.c
@@ -194,8 +194,6 @@  int sierra_ms_init(struct us_data *us)
 		kfree(swocInfo);
 	}
 complete:
-	result = device_create_file(&us->pusb_intf->dev, &dev_attr_truinst);
-
-	return 0;
+	return device_create_file(&us->pusb_intf->dev, &dev_attr_truinst);
 }