Commit 3aba70ae authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'gpio-fixes-for-v6.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

 - fix an invalid usage of __free(kfree) leading to kfreeing an
   ERR_PTR()

 - fix an irq domain leak in gpio-tb10x

 - MAINTAINERS update

* tag 'gpio-fixes-for-v6.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpio: sim: fix an invalid __free() usage
  gpio: tb10x: Fix an error handling path in tb10x_gpio_probe()
  MAINTAINERS: gpio-regmap: make myself a maintainer of it
parents 85eba5f1 5cb9606a
...@@ -8873,7 +8873,7 @@ F: drivers/gpio/gpio-mockup.c ...@@ -8873,7 +8873,7 @@ F: drivers/gpio/gpio-mockup.c
F: tools/testing/selftests/gpio/ F: tools/testing/selftests/gpio/
GPIO REGMAP GPIO REGMAP
R: Michael Walle <michael@walle.cc> M: Michael Walle <michael@walle.cc>
S: Maintained S: Maintained
F: drivers/gpio/gpio-regmap.c F: drivers/gpio/gpio-regmap.c
F: include/linux/gpio/regmap.h F: include/linux/gpio/regmap.h
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/irq_sim.h> #include <linux/irq_sim.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/minmax.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>
...@@ -685,52 +686,32 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page) ...@@ -685,52 +686,32 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page)
return sprintf(page, "%c\n", live ? '1' : '0'); return sprintf(page, "%c\n", live ? '1' : '0');
} }
static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank, static unsigned int gpio_sim_get_line_names_size(struct gpio_sim_bank *bank)
unsigned int *line_names_size)
{ {
unsigned int max_offset = 0;
bool has_line_names = false;
struct gpio_sim_line *line; struct gpio_sim_line *line;
char **line_names; unsigned int size = 0;
list_for_each_entry(line, &bank->line_list, siblings) { list_for_each_entry(line, &bank->line_list, siblings) {
if (line->offset >= bank->num_lines) if (!line->name || (line->offset >= bank->num_lines))
continue; continue;
if (line->name) { size = max(size, line->offset + 1);
if (line->offset > max_offset)
max_offset = line->offset;
/*
* max_offset can stay at 0 so it's not an indicator
* of whether line names were configured at all.
*/
has_line_names = true;
}
} }
if (!has_line_names) return size;
/* }
* This is not an error - NULL means, there are no line
* names configured.
*/
return NULL;
*line_names_size = max_offset + 1;
line_names = kcalloc(*line_names_size, sizeof(*line_names), GFP_KERNEL); static void
if (!line_names) gpio_sim_set_line_names(struct gpio_sim_bank *bank, char **line_names)
return ERR_PTR(-ENOMEM); {
struct gpio_sim_line *line;
list_for_each_entry(line, &bank->line_list, siblings) { list_for_each_entry(line, &bank->line_list, siblings) {
if (line->offset >= bank->num_lines) if (!line->name || (line->offset >= bank->num_lines))
continue; continue;
if (line->name && (line->offset <= max_offset)) line_names[line->offset] = line->name;
line_names[line->offset] = line->name;
} }
return line_names;
} }
static void gpio_sim_remove_hogs(struct gpio_sim_device *dev) static void gpio_sim_remove_hogs(struct gpio_sim_device *dev)
...@@ -834,7 +815,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank, ...@@ -834,7 +815,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
struct fwnode_handle *parent) struct fwnode_handle *parent)
{ {
struct property_entry properties[GPIO_SIM_PROP_MAX]; struct property_entry properties[GPIO_SIM_PROP_MAX];
unsigned int prop_idx = 0, line_names_size = 0; unsigned int prop_idx = 0, line_names_size;
char **line_names __free(kfree) = NULL; char **line_names __free(kfree) = NULL;
memset(properties, 0, sizeof(properties)); memset(properties, 0, sizeof(properties));
...@@ -845,14 +826,19 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank, ...@@ -845,14 +826,19 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label", properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label",
bank->label); bank->label);
line_names = gpio_sim_make_line_names(bank, &line_names_size); line_names_size = gpio_sim_get_line_names_size(bank);
if (IS_ERR(line_names)) if (line_names_size) {
return ERR_CAST(line_names); line_names = kcalloc(line_names_size, sizeof(*line_names),
GFP_KERNEL);
if (!line_names)
return ERR_PTR(-ENOMEM);
gpio_sim_set_line_names(bank, line_names);
if (line_names)
properties[prop_idx++] = PROPERTY_ENTRY_STRING_ARRAY_LEN( properties[prop_idx++] = PROPERTY_ENTRY_STRING_ARRAY_LEN(
"gpio-line-names", "gpio-line-names",
line_names, line_names_size); line_names, line_names_size);
}
return fwnode_create_software_node(properties, parent); return fwnode_create_software_node(properties, parent);
} }
......
...@@ -195,7 +195,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev) ...@@ -195,7 +195,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE, handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE,
IRQ_GC_INIT_MASK_CACHE); IRQ_GC_INIT_MASK_CACHE);
if (ret) if (ret)
return ret; goto err_remove_domain;
gc = tb10x_gpio->domain->gc->gc[0]; gc = tb10x_gpio->domain->gc->gc[0];
gc->reg_base = tb10x_gpio->base; gc->reg_base = tb10x_gpio->base;
...@@ -209,6 +209,10 @@ static int tb10x_gpio_probe(struct platform_device *pdev) ...@@ -209,6 +209,10 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
} }
return 0; return 0;
err_remove_domain:
irq_domain_remove(tb10x_gpio->domain);
return ret;
} }
static int tb10x_gpio_remove(struct platform_device *pdev) static int tb10x_gpio_remove(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment