diff mbox series

hwmon: (aquacomputer_d5next) Fix an error handling path in aqc_probe()

Message ID be6b955d50de140fcc96bd116150b435021bf567.1653225250.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Headers show
Series hwmon: (aquacomputer_d5next) Fix an error handling path in aqc_probe() | expand

Commit Message

Christophe JAILLET May 22, 2022, 1:14 p.m. UTC
If no memory can be allocated, some resources still need to be released as
already done in the other error handling paths.

Fixes: 752b927951ea ("hwmon: (aquacomputer_d5next) Add support for Aquacomputer Octo")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/hwmon/aquacomputer_d5next.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Guenter Roeck May 22, 2022, 2:35 p.m. UTC | #1
On Sun, May 22, 2022 at 03:14:23PM +0200, Christophe JAILLET wrote:
> If no memory can be allocated, some resources still need to be released as
> already done in the other error handling paths.
> 
> Fixes: 752b927951ea ("hwmon: (aquacomputer_d5next) Add support for Aquacomputer Octo")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/aquacomputer_d5next.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
> index 7d2e7279abfb..a0e69f7ece36 100644
> --- a/drivers/hwmon/aquacomputer_d5next.c
> +++ b/drivers/hwmon/aquacomputer_d5next.c
> @@ -783,8 +783,10 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  	priv->name = aqc_device_names[priv->kind];
>  
>  	priv->buffer = devm_kzalloc(&hdev->dev, priv->buffer_size, GFP_KERNEL);
> -	if (!priv->buffer)
> -		return -ENOMEM;
> +	if (!priv->buffer) {
> +		ret = -ENOMEM;
> +		goto fail_and_close;
> +	}
>  
>  	mutex_init(&priv->mutex);
>
Aleksa Savic May 22, 2022, 6:34 p.m. UTC | #2
Thank you Christophe!

Aleksa
Guenter Roeck May 22, 2022, 6:37 p.m. UTC | #3
On 5/22/22 11:34, Aleksa Savic wrote:
> Thank you Christophe!
> 
> Aleksa

A Reviewed-by: tag would be useful.

Thanks,
Guenter
Aleksa Savic May 22, 2022, 6:53 p.m. UTC | #4
On Sun, May 22, 2022 at 11:37:52AM -0700, Guenter Roeck wrote:
> On 5/22/22 11:34, Aleksa Savic wrote:
> > Thank you Christophe!
> > 
> > Aleksa
> 
> A Reviewed-by: tag would be useful.
>
> Thanks,
> Guenter

Right - that slipped my mind, sorry. For the patch:

Reviewed-by: Aleksa Savic <savicaleksa83@gmail.com>

Thanks,
Aleksa
diff mbox series

Patch

diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
index 7d2e7279abfb..a0e69f7ece36 100644
--- a/drivers/hwmon/aquacomputer_d5next.c
+++ b/drivers/hwmon/aquacomputer_d5next.c
@@ -783,8 +783,10 @@  static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	priv->name = aqc_device_names[priv->kind];
 
 	priv->buffer = devm_kzalloc(&hdev->dev, priv->buffer_size, GFP_KERNEL);
-	if (!priv->buffer)
-		return -ENOMEM;
+	if (!priv->buffer) {
+		ret = -ENOMEM;
+		goto fail_and_close;
+	}
 
 	mutex_init(&priv->mutex);