public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (xgene) Fix up error handling path mixup in 'xgene_hwmon_probe()'
@ 2017-09-23  6:44 Christophe JAILLET
  2017-10-01 14:28 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2017-09-23  6:44 UTC (permalink / raw)
  To: jdelvare, linux
  Cc: linux-hwmon, linux-kernel, kernel-janitors, Christophe JAILLET

Commit 2ca492e22cb7 has moved the call to 'kfifo_alloc()' from after the
main 'if' statement to before it.
But it has not updated the error handling paths accordingly.

Fix all that:
   - if 'kfifo_alloc()' fails we can return directly
   - direct returns after 'kfifo_alloc()' must now go to 'out_mbox_free'
   - 'goto out_mbox_free' must be replaced by 'goto out', otherwise the
     '[pcc_]mbox_free_channel()' call will be missed.

Fixes: 2ca492e22cb7 ("hwmon: (xgene) Fix crash when alarm occurs before driver probe")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/hwmon/xgene-hwmon.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
index 9c0dbb8191ad..e1be61095532 100644
--- a/drivers/hwmon/xgene-hwmon.c
+++ b/drivers/hwmon/xgene-hwmon.c
@@ -630,7 +630,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 			 sizeof(struct slimpro_resp_msg) * ASYNC_MSG_FIFO_SIZE,
 			 GFP_KERNEL);
 	if (rc)
-		goto out_mbox_free;
+		return -ENOMEM;
 
 	INIT_WORK(&ctx->workq, xgene_hwmon_evt_work);
 
@@ -646,7 +646,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		if (IS_ERR(ctx->mbox_chan)) {
 			dev_err(&pdev->dev,
 				"SLIMpro mailbox channel request failed\n");
-			return -ENODEV;
+			rc = -ENODEV;
+			goto out_mbox_free;
 		}
 	} else {
 		struct acpi_pcct_hw_reduced *cppc_ss;
@@ -654,7 +655,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		if (device_property_read_u32(&pdev->dev, "pcc-channel",
 					     &ctx->mbox_idx)) {
 			dev_err(&pdev->dev, "no pcc-channel property\n");
-			return -ENODEV;
+			rc = -ENODEV;
+			goto out_mbox_free;
 		}
 
 		cl->rx_callback = xgene_hwmon_pcc_rx_cb;
@@ -662,7 +664,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		if (IS_ERR(ctx->mbox_chan)) {
 			dev_err(&pdev->dev,
 				"PPC channel request failed\n");
-			return -ENODEV;
+			rc = -ENODEV;
+			goto out_mbox_free;
 		}
 
 		/*
@@ -675,13 +678,13 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		if (!cppc_ss) {
 			dev_err(&pdev->dev, "PPC subspace not found\n");
 			rc = -ENODEV;
-			goto out_mbox_free;
+			goto out;
 		}
 
 		if (!ctx->mbox_chan->mbox->txdone_irq) {
 			dev_err(&pdev->dev, "PCC IRQ not supported\n");
 			rc = -ENODEV;
-			goto out_mbox_free;
+			goto out;
 		}
 
 		/*
@@ -696,14 +699,14 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		} else {
 			dev_err(&pdev->dev, "Failed to get PCC comm region\n");
 			rc = -ENODEV;
-			goto out_mbox_free;
+			goto out;
 		}
 
 		if (!ctx->pcc_comm_addr) {
 			dev_err(&pdev->dev,
 				"Failed to ioremap PCC comm region\n");
 			rc = -ENOMEM;
-			goto out_mbox_free;
+			goto out;
 		}
 
 		/*
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: hwmon: (xgene) Fix up error handling path mixup in 'xgene_hwmon_probe()'
  2017-09-23  6:44 [PATCH] hwmon: (xgene) Fix up error handling path mixup in 'xgene_hwmon_probe()' Christophe JAILLET
@ 2017-10-01 14:28 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2017-10-01 14:28 UTC (permalink / raw)
  To: Christophe Jaillet; +Cc: jdelvare, linux-hwmon, linux-kernel, kernel-janitors

On Sat, Sep 23, 2017 at 08:44:15AM +0200, Christophe Jaillet wrote:
> Commit 2ca492e22cb7 has moved the call to 'kfifo_alloc()' from after the
> main 'if' statement to before it.
> But it has not updated the error handling paths accordingly.
> 
> Fix all that:
>    - if 'kfifo_alloc()' fails we can return directly
>    - direct returns after 'kfifo_alloc()' must now go to 'out_mbox_free'
>    - 'goto out_mbox_free' must be replaced by 'goto out', otherwise the
>      '[pcc_]mbox_free_channel()' call will be missed.
> 
> Fixes: 2ca492e22cb7 ("hwmon: (xgene) Fix crash when alarm occurs before driver probe")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/xgene-hwmon.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
> index 9c0dbb8191ad..e1be61095532 100644
> --- a/drivers/hwmon/xgene-hwmon.c
> +++ b/drivers/hwmon/xgene-hwmon.c
> @@ -630,7 +630,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
>  			 sizeof(struct slimpro_resp_msg) * ASYNC_MSG_FIFO_SIZE,
>  			 GFP_KERNEL);
>  	if (rc)
> -		goto out_mbox_free;
> +		return -ENOMEM;
>  
>  	INIT_WORK(&ctx->workq, xgene_hwmon_evt_work);
>  
> @@ -646,7 +646,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
>  		if (IS_ERR(ctx->mbox_chan)) {
>  			dev_err(&pdev->dev,
>  				"SLIMpro mailbox channel request failed\n");
> -			return -ENODEV;
> +			rc = -ENODEV;
> +			goto out_mbox_free;
>  		}
>  	} else {
>  		struct acpi_pcct_hw_reduced *cppc_ss;
> @@ -654,7 +655,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
>  		if (device_property_read_u32(&pdev->dev, "pcc-channel",
>  					     &ctx->mbox_idx)) {
>  			dev_err(&pdev->dev, "no pcc-channel property\n");
> -			return -ENODEV;
> +			rc = -ENODEV;
> +			goto out_mbox_free;
>  		}
>  
>  		cl->rx_callback = xgene_hwmon_pcc_rx_cb;
> @@ -662,7 +664,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
>  		if (IS_ERR(ctx->mbox_chan)) {
>  			dev_err(&pdev->dev,
>  				"PPC channel request failed\n");
> -			return -ENODEV;
> +			rc = -ENODEV;
> +			goto out_mbox_free;
>  		}
>  
>  		/*
> @@ -675,13 +678,13 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
>  		if (!cppc_ss) {
>  			dev_err(&pdev->dev, "PPC subspace not found\n");
>  			rc = -ENODEV;
> -			goto out_mbox_free;
> +			goto out;
>  		}
>  
>  		if (!ctx->mbox_chan->mbox->txdone_irq) {
>  			dev_err(&pdev->dev, "PCC IRQ not supported\n");
>  			rc = -ENODEV;
> -			goto out_mbox_free;
> +			goto out;
>  		}
>  
>  		/*
> @@ -696,14 +699,14 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
>  		} else {
>  			dev_err(&pdev->dev, "Failed to get PCC comm region\n");
>  			rc = -ENODEV;
> -			goto out_mbox_free;
> +			goto out;
>  		}
>  
>  		if (!ctx->pcc_comm_addr) {
>  			dev_err(&pdev->dev,
>  				"Failed to ioremap PCC comm region\n");
>  			rc = -ENOMEM;
> -			goto out_mbox_free;
> +			goto out;
>  		}
>  
>  		/*

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-01 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-23  6:44 [PATCH] hwmon: (xgene) Fix up error handling path mixup in 'xgene_hwmon_probe()' Christophe JAILLET
2017-10-01 14:28 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox