Skip to contentSkip to conversation

pinctrl: single: check for any error when getting rows

PATCH Superseded Axel Haslam 2 participants 2 messages Nov 9, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: single: check for any error when getting rows

pinctrl_count_index_with_args returns -ENOENT not -EINVAL. The return check would pass, and we would try to kzalloc with a negative error size throwing a warning.

Instead of checking for -EINVAL specifically, lets check for any error and avoid negative size allocations.

---
 drivers/pinctrl/pinctrl-single.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-single.c +1 -1
index 539f31c..56e22be 100644
@@ -1228,7 +1228,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 	struct pcs_function *function;
 
 	rows = pinctrl_count_index_with_args(np, name);
-	if (rows == -EINVAL)
+	if (rows < 0)
 		return rows;
 
 	npins_in_row = pcs->width / pcs->bits_per_pin;
Signature · 1 line
2.10.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Axel Haslam

pinctrl_count_index_with_args returns -ENOENT not -EINVAL. The return check would pass, and we would try to kzalloc with a negative error size throwing a warning.

Instead of checking for -EINVAL specifically, lets check for any error and avoid negative size allocations.

Thanks for fixing that:

Quoted 20 lines
---
 drivers/pinctrl/pinctrl-single.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-single.c +1 -1
index 539f31c..56e22be 100644
@@ -1228,7 +1228,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 	struct pcs_function *function;
 
 	rows = pinctrl_count_index_with_args(np, name);
-	if (rows == -EINVAL)
+	if (rows < 0)
 		return rows;
 
 	npins_in_row = pcs->width / pcs->bits_per_pin;
Signature · 1 line
2.10.1