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

+29 -39
+1 -1
MAINTAINERS
··· 8873 8873 F: tools/testing/selftests/gpio/ 8874 8874 8875 8875 GPIO REGMAP 8876 - R: Michael Walle <michael@walle.cc> 8876 + M: Michael Walle <michael@walle.cc> 8877 8877 S: Maintained 8878 8878 F: drivers/gpio/gpio-regmap.c 8879 8879 F: include/linux/gpio/regmap.h
+23 -37
drivers/gpio/gpio-sim.c
··· 19 19 #include <linux/irq.h> 20 20 #include <linux/irq_sim.h> 21 21 #include <linux/list.h> 22 + #include <linux/minmax.h> 22 23 #include <linux/mod_devicetable.h> 23 24 #include <linux/module.h> 24 25 #include <linux/mutex.h> ··· 686 685 return sprintf(page, "%c\n", live ? '1' : '0'); 687 686 } 688 687 689 - static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank, 690 - unsigned int *line_names_size) 688 + static unsigned int gpio_sim_get_line_names_size(struct gpio_sim_bank *bank) 691 689 { 692 - unsigned int max_offset = 0; 693 - bool has_line_names = false; 694 690 struct gpio_sim_line *line; 695 - char **line_names; 691 + unsigned int size = 0; 696 692 697 693 list_for_each_entry(line, &bank->line_list, siblings) { 698 - if (line->offset >= bank->num_lines) 694 + if (!line->name || (line->offset >= bank->num_lines)) 699 695 continue; 700 696 701 - if (line->name) { 702 - if (line->offset > max_offset) 703 - max_offset = line->offset; 704 - 705 - /* 706 - * max_offset can stay at 0 so it's not an indicator 707 - * of whether line names were configured at all. 708 - */ 709 - has_line_names = true; 710 - } 697 + size = max(size, line->offset + 1); 711 698 } 712 699 713 - if (!has_line_names) 714 - /* 715 - * This is not an error - NULL means, there are no line 716 - * names configured. 717 - */ 718 - return NULL; 700 + return size; 701 + } 719 702 720 - *line_names_size = max_offset + 1; 721 - 722 - line_names = kcalloc(*line_names_size, sizeof(*line_names), GFP_KERNEL); 723 - if (!line_names) 724 - return ERR_PTR(-ENOMEM); 703 + static void 704 + gpio_sim_set_line_names(struct gpio_sim_bank *bank, char **line_names) 705 + { 706 + struct gpio_sim_line *line; 725 707 726 708 list_for_each_entry(line, &bank->line_list, siblings) { 727 - if (line->offset >= bank->num_lines) 709 + if (!line->name || (line->offset >= bank->num_lines)) 728 710 continue; 729 711 730 - if (line->name && (line->offset <= max_offset)) 731 - line_names[line->offset] = line->name; 712 + line_names[line->offset] = line->name; 732 713 } 733 - 734 - return line_names; 735 714 } 736 715 737 716 static void gpio_sim_remove_hogs(struct gpio_sim_device *dev) ··· 815 834 struct fwnode_handle *parent) 816 835 { 817 836 struct property_entry properties[GPIO_SIM_PROP_MAX]; 818 - unsigned int prop_idx = 0, line_names_size = 0; 837 + unsigned int prop_idx = 0, line_names_size; 819 838 char **line_names __free(kfree) = NULL; 820 839 821 840 memset(properties, 0, sizeof(properties)); ··· 826 845 properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label", 827 846 bank->label); 828 847 829 - line_names = gpio_sim_make_line_names(bank, &line_names_size); 830 - if (IS_ERR(line_names)) 831 - return ERR_CAST(line_names); 848 + line_names_size = gpio_sim_get_line_names_size(bank); 849 + if (line_names_size) { 850 + line_names = kcalloc(line_names_size, sizeof(*line_names), 851 + GFP_KERNEL); 852 + if (!line_names) 853 + return ERR_PTR(-ENOMEM); 832 854 833 - if (line_names) 855 + gpio_sim_set_line_names(bank, line_names); 856 + 834 857 properties[prop_idx++] = PROPERTY_ENTRY_STRING_ARRAY_LEN( 835 858 "gpio-line-names", 836 859 line_names, line_names_size); 860 + } 837 861 838 862 return fwnode_create_software_node(properties, parent); 839 863 }
+5 -1
drivers/gpio/gpio-tb10x.c
··· 195 195 handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE, 196 196 IRQ_GC_INIT_MASK_CACHE); 197 197 if (ret) 198 - return ret; 198 + goto err_remove_domain; 199 199 200 200 gc = tb10x_gpio->domain->gc->gc[0]; 201 201 gc->reg_base = tb10x_gpio->base; ··· 209 209 } 210 210 211 211 return 0; 212 + 213 + err_remove_domain: 214 + irq_domain_remove(tb10x_gpio->domain); 215 + return ret; 212 216 } 213 217 214 218 static int tb10x_gpio_remove(struct platform_device *pdev)