diff mbox series

usb: misc: usb3503: Fix logic in usb3503_init()

Message ID 4ae929dc31c170252154352d04e89c8456d91ca3.1612870239.git.michal.simek@xilinx.com
State New
Headers show
Series usb: misc: usb3503: Fix logic in usb3503_init() | expand

Commit Message

Michal Simek Feb. 9, 2021, 11:30 a.m. UTC
Based on
https://lore.kernel.org/linux-arm-kernel/YCJv59g3Tq2haDSa@kroah.com/
initialization should fail if any registration fails.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/usb/misc/usb3503.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Greg KH Feb. 9, 2021, 11:59 a.m. UTC | #1
On Tue, Feb 09, 2021 at 12:30:42PM +0100, Michal Simek wrote:
> Based on
> https://lore.kernel.org/linux-arm-kernel/YCJv59g3Tq2haDSa@kroah.com/
> initialization should fail if any registration fails.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>  drivers/usb/misc/usb3503.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
> index 48099c6bf04c..3aae83fbebae 100644
> --- a/drivers/usb/misc/usb3503.c
> +++ b/drivers/usb/misc/usb3503.c
> @@ -409,13 +409,17 @@ static int __init usb3503_init(void)
>  	int err;
>  
>  	err = i2c_add_driver(&usb3503_i2c_driver);
> -	if (err != 0)
> +	if (err) {
>  		pr_err("usb3503: Failed to register I2C driver: %d\n", err);
> +		return err;
> +	}
>  
>  	err = platform_driver_register(&usb3503_platform_driver);
> -	if (err != 0)
> +	if (err) {
>  		pr_err("usb3503: Failed to register platform driver: %d\n",
>  		       err);
> +		return err;

You just left a i2c driver registered :(
Johan Hovold Feb. 9, 2021, 12:01 p.m. UTC | #2
On Tue, Feb 09, 2021 at 12:30:42PM +0100, Michal Simek wrote:
> Based on
> https://lore.kernel.org/linux-arm-kernel/YCJv59g3Tq2haDSa@kroah.com/
> initialization should fail if any registration fails.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>  drivers/usb/misc/usb3503.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
> index 48099c6bf04c..3aae83fbebae 100644
> --- a/drivers/usb/misc/usb3503.c
> +++ b/drivers/usb/misc/usb3503.c
> @@ -409,13 +409,17 @@ static int __init usb3503_init(void)
>  	int err;
>  
>  	err = i2c_add_driver(&usb3503_i2c_driver);
> -	if (err != 0)
> +	if (err) {
>  		pr_err("usb3503: Failed to register I2C driver: %d\n", err);
> +		return err;
> +	}
>  
>  	err = platform_driver_register(&usb3503_platform_driver);
> -	if (err != 0)
> +	if (err) {
>  		pr_err("usb3503: Failed to register platform driver: %d\n",
>  		       err);

You forgot to deregister the i2c driver.

> +		return err;
> +	}
>  
>  	return 0;
>  }

Johan
diff mbox series

Patch

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index 48099c6bf04c..3aae83fbebae 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -409,13 +409,17 @@  static int __init usb3503_init(void)
 	int err;
 
 	err = i2c_add_driver(&usb3503_i2c_driver);
-	if (err != 0)
+	if (err) {
 		pr_err("usb3503: Failed to register I2C driver: %d\n", err);
+		return err;
+	}
 
 	err = platform_driver_register(&usb3503_platform_driver);
-	if (err != 0)
+	if (err) {
 		pr_err("usb3503: Failed to register platform driver: %d\n",
 		       err);
+		return err;
+	}
 
 	return 0;
 }