diff mbox series

USB: serial: Remove redundant NULL check before release_firmware() call

Message ID 20220606014315.290533-1-chi.minghao@zte.com.cn
State New
Headers show
Series USB: serial: Remove redundant NULL check before release_firmware() call | expand

Commit Message

Lv Ruyi June 6, 2022, 1:43 a.m. UTC
From: Minghao Chi <chi.minghao@zte.com.cn>

release_firmware() checks for NULL pointers internally so checking
before calling it is redundant.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
 drivers/usb/serial/mxuport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Johan Hovold June 9, 2022, 12:43 p.m. UTC | #1
On Mon, Jun 06, 2022 at 01:43:15AM +0000, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> release_firmware() checks for NULL pointers internally so checking
> before calling it is redundant.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>

Cleanups do not deserve a Reported-by tag, and neither do reports that
are never posted to the mailing lists.

> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
>  drivers/usb/serial/mxuport.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> index eb45a9b0005c..eb9090ab900f 100644
> --- a/drivers/usb/serial/mxuport.c
> +++ b/drivers/usb/serial/mxuport.c
> @@ -1109,8 +1109,7 @@ static int mxuport_probe(struct usb_serial *serial,
>  	 */
>  	usb_set_serial_data(serial, (void *)id->driver_info);
>  out:
> -	if (fw_p)
> -		release_firmware(fw_p);
> +	release_firmware(fw_p);

I think keeping this check is preferred here as it makes the intent of
code more clear (and you don't have to check the definition of
release_firmware() to make sure it's safe to pass in NULL).

>  	return err;
>  }

Johan
diff mbox series

Patch

diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index eb45a9b0005c..eb9090ab900f 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -1109,8 +1109,7 @@  static int mxuport_probe(struct usb_serial *serial,
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);
 	return err;
 }