|
|
@@ -2279,6 +2279,12 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
|
|
unsigned long flags;
|
|
|
unsigned offset;
|
|
|
|
|
|
+ if (label) {
|
|
|
+ label = kstrdup_const(label, GFP_KERNEL);
|
|
|
+ if (!label)
|
|
|
+ return -ENOMEM;
|
|
|
+ }
|
|
|
+
|
|
|
spin_lock_irqsave(&gpio_lock, flags);
|
|
|
|
|
|
/* NOTE: gpio_request() can be called in early boot,
|
|
|
@@ -2289,6 +2295,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
|
|
desc_set_label(desc, label ? : "?");
|
|
|
status = 0;
|
|
|
} else {
|
|
|
+ kfree_const(label);
|
|
|
status = -EBUSY;
|
|
|
goto done;
|
|
|
}
|
|
|
@@ -2305,6 +2312,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
|
|
|
|
|
if (status < 0) {
|
|
|
desc_set_label(desc, NULL);
|
|
|
+ kfree_const(label);
|
|
|
clear_bit(FLAG_REQUESTED, &desc->flags);
|
|
|
goto done;
|
|
|
}
|
|
|
@@ -2400,6 +2408,7 @@ static bool gpiod_free_commit(struct gpio_desc *desc)
|
|
|
chip->free(chip, gpio_chip_hwgpio(desc));
|
|
|
spin_lock_irqsave(&gpio_lock, flags);
|
|
|
}
|
|
|
+ kfree_const(desc->label);
|
|
|
desc_set_label(desc, NULL);
|
|
|
clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
|
|
|
clear_bit(FLAG_REQUESTED, &desc->flags);
|
|
|
@@ -3221,11 +3230,19 @@ EXPORT_SYMBOL_GPL(gpiod_cansleep);
|
|
|
* @desc: gpio to set the consumer name on
|
|
|
* @name: the new consumer name
|
|
|
*/
|
|
|
-void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
|
|
|
+int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
|
|
|
{
|
|
|
- VALIDATE_DESC_VOID(desc);
|
|
|
- /* Just overwrite whatever the previous name was */
|
|
|
- desc->label = name;
|
|
|
+ VALIDATE_DESC(desc);
|
|
|
+ if (name) {
|
|
|
+ name = kstrdup_const(name, GFP_KERNEL);
|
|
|
+ if (!name)
|
|
|
+ return -ENOMEM;
|
|
|
+ }
|
|
|
+
|
|
|
+ kfree_const(desc->label);
|
|
|
+ desc_set_label(desc, name);
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(gpiod_set_consumer_name);
|
|
|
|