Skip to contentSkip to conversation

extcon: use correct size

PATCH In review Dan Carpenter 5 participants 6 messages Feb 4, 2016 – Feb 5, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extcon: use correct size

The info->status[] array has 3 elements. We are using size MAX77843_MUIC_IRQ_NUM (16) instead of MAX77843_MUIC_STATUS_NUM (3) as intended.

Fixes 135d9f7d135a ('extcon: max77843: Clear IRQ bits state before request IRQ')

---
This is from static analysis and *NOT TESTED*. Please review carefully.

drivers/extcon/extcon-max77843.c +1 -1
index 7bbc300..b188bd6 100644
@@ -806,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 	/* Clear IRQ bits before request IRQs */
 	ret = regmap_bulk_read(max77843->regmap_muic,
 			MAX77843_MUIC_REG_INT1, info->status,
-			MAX77843_MUIC_IRQ_NUM);
+			MAX77843_MUIC_STATUS_NUM);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
 		goto err_muic_irq;
#1 lore raw

Am 04.02.2016 12:36, schrieb Dan Carpenter:

Quoted 14 lines

The info->status[] array has 3 elements. We are using size MAX77843_MUIC_IRQ_NUM (16) instead of MAX77843_MUIC_STATUS_NUM (3) as intended.

Fixes 135d9f7d135a ('extcon: max77843: Clear IRQ bits state before request IRQ')

---
This is from static analysis and *NOT TESTED*. Please review carefully.

drivers/extcon/extcon-max77843.c +0 -0
index 7bbc300..b188bd6 100644

drivers/extcon/extcon-max77843.c static int max77843_muic_probe(struct platform_device *pdev)

Quoted 9 lines
drivers/extcon/extcon-max77843.c +1 -2
@@ -806,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 	/* Clear IRQ bits before request IRQs */
 	ret = regmap_bulk_read(max77843->regmap_muic,
 			MAX77843_MUIC_REG_INT1, info->status,
-			MAX77843_MUIC_IRQ_NUM);
+			MAX77843_MUIC_STATUS_NUM);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
 		goto err_muic_irq;
--

just for my curiosity: what is wrong with ARRAY_SIZE() ? So far i understand is the functions intention to fill the array completely.

re,
wh

#2 lore raw
Quoted 23 lines · walter harms

Am 04.02.2016 12:36, schrieb Dan Carpenter:

Quoted 20 lines

The info->status[] array has 3 elements. We are using size MAX77843_MUIC_IRQ_NUM (16) instead of MAX77843_MUIC_STATUS_NUM (3) as intended.

Fixes 135d9f7d135a ('extcon: max77843: Clear IRQ bits state before request IRQ')

---
This is from static analysis and *NOT TESTED*. Please review carefully.

drivers/extcon/extcon-max77843.c +1 -1
index 7bbc300..b188bd6 100644
@@ -806,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 	/* Clear IRQ bits before request IRQs */
 	ret = regmap_bulk_read(max77843->regmap_muic,
 			MAX77843_MUIC_REG_INT1, info->status,
-			MAX77843_MUIC_IRQ_NUM);
+			MAX77843_MUIC_STATUS_NUM);
 	if (ret) {
Quoted 8 lines

drivers/extcon/extcon-max77843.c static int max77843_muic_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/extcon/extcon-max77843.c +0 -1
 		dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
 		goto err_muic_irq;
--

just for my curiosity: what is wrong with ARRAY_SIZE() ? So far i understand is the functions intention to fill the array completely.

It's done pretty consistently the one way... Jaewon?

regards,
dan carpenter

Reviewed-by
#3 lore raw

Hi, Dan

Quoted 9 lines · 02/05/2016 04:53 AM¿¡ Dan Carpenter wrote:
Quoted 7 lines · walter harms

Am 04.02.2016 12:36, schrieb Dan Carpenter:

Quoted 4 lines

The info->status[] array has 3 elements. We are using size MAX77843_MUIC_IRQ_NUM (16) instead of MAX77843_MUIC_STATUS_NUM (3) as intended.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Fixes 135d9f7d135a ('extcon: max77843: Clear IRQ bits state

before request IRQ')

---
This is from static analysis and *NOT TESTED*. Please review

carefully.

Quoted 7 lines
Quoted 7 lines

drivers/extcon/extcon-max77843.c static int max77843_muic_probe(struct

Quoted 7 lines
drivers/extcon/extcon-max77843.c +0 -0
index 7bbc300..b188bd6 100644
@@ -806,7 +806,7 @@ static int max77843_muic_probe(struct

platform_device *pdev)

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/extcon/extcon-max77843.c +1 -1
 	/* Clear IRQ bits before request IRQs */
 	ret = regmap_bulk_read(max77843->regmap_muic,
 			MAX77843_MUIC_REG_INT1, info->status,
-			MAX77843_MUIC_IRQ_NUM);
+			MAX77843_MUIC_STATUS_NUM);
 	if (ret) {
Quoted 8 lines

drivers/extcon/extcon-max77843.c static int max77843_muic_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/extcon/extcon-max77843.c +0 -1
 		dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
 		goto err_muic_irq;
--

just for my curiosity: what is wrong with ARRAY_SIZE() ? So far i understand is the functions intention to fill the array completely.

Quoted 5 lines

It's done pretty consistently the one way... Jaewon?

regards,
dan carpenter

You are right.
We should read only 3-sequential register. (MAX77843_MUIC_REG_INT1, MAX77843_MUIC_REG_INT2, MAX77843_MUIC_REG_INT3)

Thanks
Jaewon Kim

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v1 1/1
#4 lore raw
In reply to Dan Carpenter

2016-02-04 20:36 GMT+09:00 Dan Carpenter <[email protected]>:

Quoted 14 lines

The info->status[] array has 3 elements. We are using size MAX77843_MUIC_IRQ_NUM (16) instead of MAX77843_MUIC_STATUS_NUM (3) as intended.

Fixes 135d9f7d135a ('extcon: max77843: Clear IRQ bits state before request IRQ')

---
This is from static analysis and *NOT TESTED*. Please review carefully.

drivers/extcon/extcon-max77843.c +0 -0
index 7bbc300..b188bd6 100644

drivers/extcon/extcon-max77843.c static int max77843_muic_probe(struct platform_device *pdev) · line 812

Quoted 8 lines
drivers/extcon/extcon-max77843.c +1 -1
@@ -806,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
        /* Clear IRQ bits before request IRQs */
        ret = regmap_bulk_read(max77843->regmap_muic,
                        MAX77843_MUIC_REG_INT1, info->status,
-                       MAX77843_MUIC_IRQ_NUM);
+                       MAX77843_MUIC_STATUS_NUM);
        if (ret) {
                dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
                goto err_muic_irq;

Looks correct. Issue came from our internal tree where MAX77843_MUIC_IRQ_NUM is redefined to a value of 3.

However the subject should be fixed to match the subsystem and more accurately describe the error.

Best regards,
Krzysztof

maintainer
#5 lore raw
In reply to Dan Carpenter

Hi Dan,

Quoted 16 lines · Dan Carpenter

The info->status[] array has 3 elements. We are using size MAX77843_MUIC_IRQ_NUM (16) instead of MAX77843_MUIC_STATUS_NUM (3) as intended.

Fixes 135d9f7d135a ('extcon: max77843: Clear IRQ bits state before request IRQ')

---
This is from static analysis and *NOT TESTED*. Please review carefully.

drivers/extcon/extcon-max77843.c +0 -0
index 7bbc300..b188bd6 100644

drivers/extcon/extcon-max77843.c static int max77843_muic_probe(struct platform_device *pdev) · line 812

Quoted 8 lines
drivers/extcon/extcon-max77843.c +1 -1
@@ -806,7 +806,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 	/* Clear IRQ bits before request IRQs */
 	ret = regmap_bulk_read(max77843->regmap_muic,
 			MAX77843_MUIC_REG_INT1, info->status,
-			MAX77843_MUIC_IRQ_NUM);
+			MAX77843_MUIC_STATUS_NUM);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to Clear IRQ bits\n");
 		goto err_muic_irq;

The patch title should include the correct information of specific device.

extcon: use correct size
-> extcon: max77843: Use correct size for reading the interrupt register

Applied it.

Thanks,
Chanwoo Choi