Skip to contentSkip to conversation

gpio: sim: check the label length when setting up device properties

PATCH In review Bartosz Golaszewski 2 participants 3 messages Jan 20, 2022 – Jan 24, 2022 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: sim: check the label length when setting up device properties

If the user-space sets the chip label to an empty string - we should check the length and assign the default name or otherwise line hogs will not be properly attached.

Fixes cb8c474e79be ("gpio: sim: new testing module")
---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +1 -1
index 838bbfed11d3..04b137eca8da 100644
@@ -816,7 +816,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
 
 	properties[prop_idx++] = PROPERTY_ENTRY_U32("ngpios", bank->num_lines);
 
-	if (bank->label)
+	if (bank->label && (strlen(bank->label) > 0))
 		properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label",
 							       bank->label);
 
Signature · 1 line
2.30.1
#1 lore raw
Quoted 4 lines · Bartosz Golaszewski

If the user-space sets the chip label to an empty string - we should check the length and assign the default name or otherwise line hogs will not be properly attached.

"assign" -> "not override"?

Cheers,
Kent.

Quoted 22 lines
Fixes cb8c474e79be ("gpio: sim: new testing module")
---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +1 -1
index 838bbfed11d3..04b137eca8da 100644
@@ -816,7 +816,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
 
 	properties[prop_idx++] = PROPERTY_ENTRY_U32("ngpios", bank->num_lines);
 
-	if (bank->label)
+	if (bank->label && (strlen(bank->label) > 0))
 		properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label",
 							       bank->label);
 
Signature · 1 line
2.30.1
#2 lore raw
Quoted 26 lines · Kent Gibson
Quoted 4 lines · Bartosz Golaszewski

If the user-space sets the chip label to an empty string - we should check the length and assign the default name or otherwise line hogs will not be properly attached.

"assign" -> "not override"?

Cheers,
Kent.

Quoted 14 lines
Fixes cb8c474e79be ("gpio: sim: new testing module")
---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +0 -0
index 838bbfed11d3..04b137eca8da 100644
@@ -816,7 +816,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
 
      properties[prop_idx++] = PROPERTY_ENTRY_U32("ngpios", bank->num_lines);
 
Quoted 8 lines
Quoted 8 lines
drivers/gpio/gpio-sim.c +1 -2
-     if (bank->label)
+     if (bank->label && (strlen(bank->label) > 0))
              properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label",
                                                             bank->label);
 
--

2.30.1

Fixed when applying.

Bart