diff mbox

rtc: max77686: Properly handle regmap_irq_get_virq() error code

Message ID 1454545595-31725-1-git-send-email-k.kozlowski@samsung.com
State Accepted
Headers show

Commit Message

Krzysztof Kozlowski Feb. 4, 2016, 12:26 a.m. UTC
The regmap_irq_get_virq() can return 0 or -EINVAL in error conditions
but driver checked only for value of 0.

This could lead to a cast of -EINVAL to an unsigned int used as a
interrupt number for devm_request_threaded_irq(). Although this is not
yet fatal (devm_request_threaded_irq() will just fail with -EINVAL) but
might be a misleading when diagnosing errors.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: 6f1c1e71d933 ("mfd: max77686: Convert to use regmap_irq")

---

Patch rebased on current mainline, not RTC tree, because IMHO it is
a candidate for current RC-cycle.

Not marking cc-stable because behavior is not fatal - unless there is
an interrupt with number 4294967274 (then it would be successfully
requested for RTC driver).
---
 drivers/rtc/rtc-max77686.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Javier Martinez Canillas Feb. 4, 2016, 2:47 a.m. UTC | #1
Hello Krzysztof,

On 02/03/2016 09:26 PM, Krzysztof Kozlowski wrote:
> The regmap_irq_get_virq() can return 0 or -EINVAL in error conditions
> but driver checked only for value of 0.
>
> This could lead to a cast of -EINVAL to an unsigned int used as a
> interrupt number for devm_request_threaded_irq(). Although this is not
> yet fatal (devm_request_threaded_irq() will just fail with -EINVAL) but
> might be a misleading when diagnosing errors.
>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Fixes: 6f1c1e71d933 ("mfd: max77686: Convert to use regmap_irq")
>
> ---
>

Good catch.

Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

Best regards,
Alexandre Belloni Feb. 4, 2016, 10:49 p.m. UTC | #2
On 04/02/2016 at 09:26:35 +0900, Krzysztof Kozlowski wrote :
> The regmap_irq_get_virq() can return 0 or -EINVAL in error conditions
> but driver checked only for value of 0.
> 
> This could lead to a cast of -EINVAL to an unsigned int used as a
> interrupt number for devm_request_threaded_irq(). Although this is not
> yet fatal (devm_request_threaded_irq() will just fail with -EINVAL) but
> might be a misleading when diagnosing errors.
> 
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Fixes: 6f1c1e71d933 ("mfd: max77686: Convert to use regmap_irq")
> 
> ---
> 
> Patch rebased on current mainline, not RTC tree, because IMHO it is
> a candidate for current RC-cycle.
> 
> Not marking cc-stable because behavior is not fatal - unless there is
> an interrupt with number 4294967274 (then it would be successfully
> requested for RTC driver).
> ---
>  drivers/rtc/rtc-max77686.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Applied, thanks.
diff mbox

Patch

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 7184a0eda793..725dccae24e7 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -465,7 +465,7 @@  static int max77686_rtc_probe(struct platform_device *pdev)
 
 	info->virq = regmap_irq_get_virq(max77686->rtc_irq_data,
 					 MAX77686_RTCIRQ_RTCA1);
-	if (!info->virq) {
+	if (info->virq <= 0) {
 		ret = -ENXIO;
 		goto err_rtc;
 	}