Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull gpio fixes from Bartosz Golaszewski:

- make sure GPIO devices are registered with the subsystem before
trying to return them to a caller of gpio_device_find()

- fix two issues with incorrect sanitization of the interrupt labels

* tag 'gpio-fixes-for-v6.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
gpio: cdev: fix missed label sanitizing in debounce_setup()
gpio: cdev: check for NULL labels when sanitizing them for irqs
gpiolib: Fix triggering "kobject: 'gpiochipX' is not initialized, yet" kobject_get() errors

+35 -16
+32 -16
drivers/gpio/gpiolib-cdev.c
··· 728 728 GPIO_V2_LINE_EVENT_FALLING_EDGE; 729 729 } 730 730 731 + static inline char *make_irq_label(const char *orig) 732 + { 733 + char *new; 734 + 735 + if (!orig) 736 + return NULL; 737 + 738 + new = kstrdup_and_replace(orig, '/', ':', GFP_KERNEL); 739 + if (!new) 740 + return ERR_PTR(-ENOMEM); 741 + 742 + return new; 743 + } 744 + 745 + static inline void free_irq_label(const char *label) 746 + { 747 + kfree(label); 748 + } 749 + 731 750 #ifdef CONFIG_HTE 732 751 733 752 static enum hte_return process_hw_ts_thread(void *p) ··· 1034 1015 { 1035 1016 unsigned long irqflags; 1036 1017 int ret, level, irq; 1018 + char *label; 1037 1019 1038 1020 /* try hardware */ 1039 1021 ret = gpiod_set_debounce(line->desc, debounce_period_us); ··· 1057 1037 if (irq < 0) 1058 1038 return -ENXIO; 1059 1039 1040 + label = make_irq_label(line->req->label); 1041 + if (IS_ERR(label)) 1042 + return -ENOMEM; 1043 + 1060 1044 irqflags = IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING; 1061 1045 ret = request_irq(irq, debounce_irq_handler, irqflags, 1062 - line->req->label, line); 1063 - if (ret) 1046 + label, line); 1047 + if (ret) { 1048 + free_irq_label(label); 1064 1049 return ret; 1050 + } 1065 1051 line->irq = irq; 1066 1052 } else { 1067 1053 ret = hte_edge_setup(line, GPIO_V2_LINE_FLAG_EDGE_BOTH); ··· 1107 1081 return lc->attrs[i].attr.debounce_period_us; 1108 1082 } 1109 1083 return 0; 1110 - } 1111 - 1112 - static inline char *make_irq_label(const char *orig) 1113 - { 1114 - return kstrdup_and_replace(orig, '/', ':', GFP_KERNEL); 1115 - } 1116 - 1117 - static inline void free_irq_label(const char *label) 1118 - { 1119 - kfree(label); 1120 1084 } 1121 1085 1122 1086 static void edge_detector_stop(struct line *line) ··· 1174 1158 irqflags |= IRQF_ONESHOT; 1175 1159 1176 1160 label = make_irq_label(line->req->label); 1177 - if (!label) 1178 - return -ENOMEM; 1161 + if (IS_ERR(label)) 1162 + return PTR_ERR(label); 1179 1163 1180 1164 /* Request a thread to read the events */ 1181 1165 ret = request_threaded_irq(irq, edge_irq_handler, edge_irq_thread, ··· 2233 2217 goto out_free_le; 2234 2218 2235 2219 label = make_irq_label(le->label); 2236 - if (!label) { 2237 - ret = -ENOMEM; 2220 + if (IS_ERR(label)) { 2221 + ret = PTR_ERR(label); 2238 2222 goto out_free_le; 2239 2223 } 2240 2224
+3
drivers/gpio/gpiolib.c
··· 1175 1175 1176 1176 list_for_each_entry_srcu(gdev, &gpio_devices, list, 1177 1177 srcu_read_lock_held(&gpio_devices_srcu)) { 1178 + if (!device_is_registered(&gdev->dev)) 1179 + continue; 1180 + 1178 1181 guard(srcu)(&gdev->srcu); 1179 1182 1180 1183 gc = srcu_dereference(gdev->chip, &gdev->srcu);