Skip to content

Commit b4818eb

Browse files
committed
Merge: pinctrl: intel: platform: updates to fix error path in device_for_each_child_node()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5763 Description: updates for pinctrl: intel: platform: fix error path in device_for_each_child_node() JIRA: https://issues.redhat.com/browse/RHEL-66957 CVE: CVE-2024-50197 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=65873024 Tested: Successful platform test results on Intel (intel-arrowlake-h-01) system. The following 8 commits are not fixes to 365130f they just use the new routine provide by 365130f. If needed in the future they can be bought in individually. Trying to limit the changes for this CVE and that is another reason to not bring them in now. Omitted-fix: d13df21 ("Input: adcto -joystick - use device_for_each_child_node_scoped()") Omitted-fix: 44f9c7c ("Input: adc-keys - use device_for_each_child_node_scoped()") Omitted-fix: 1102db7 ("Input: gpio_keys_polled - use device_for_each_child_node_scoped()") Omitted-fix: c90a851 ("Input: gpio_keys - use device_for_each_child_node_scoped()") Omitted-fix: 4f210af ("Input: qt1050 - use device_for_each_child_node_scoped()") Omitted-fix: 4256d47 ("Input: iqs269a - use device_for_each_child_node_scoped()") Omitted-fix: 1ee1237 ("hwmon: (gsc-hwmon) use device_for_each_child_node_scoped()") Omitted-fix: 234c074 ("hwmon: (ltc2991) use device_for_each_child_node_scoped()") Signed-off-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Desnes Nunes <desnesn@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents ebb3c47 + 17948f3 commit b4818eb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

drivers/pinctrl/intel/pinctrl-intel-platform.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ static int intel_platform_pinctrl_prepare_community(struct device *dev,
9090
struct intel_community *community,
9191
struct intel_platform_pins *pins)
9292
{
93-
struct fwnode_handle *child;
9493
struct intel_padgroup *gpps;
9594
unsigned int group;
9695
size_t ngpps;
@@ -131,7 +130,7 @@ static int intel_platform_pinctrl_prepare_community(struct device *dev,
131130
return -ENOMEM;
132131

133132
group = 0;
134-
device_for_each_child_node(dev, child) {
133+
device_for_each_child_node_scoped(dev, child) {
135134
struct intel_padgroup *gpp = &gpps[group];
136135

137136
gpp->reg_num = group;

include/linux/property.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LINUX_PROPERTY_H_
1212

1313
#include <linux/bits.h>
14+
#include <linux/cleanup.h>
1415
#include <linux/fwnode.h>
1516
#include <linux/types.h>
1617

@@ -140,6 +141,11 @@ struct fwnode_handle *device_get_next_child_node(const struct device *dev,
140141
for (child = device_get_next_child_node(dev, NULL); child; \
141142
child = device_get_next_child_node(dev, child))
142143

144+
#define device_for_each_child_node_scoped(dev, child) \
145+
for (struct fwnode_handle *child __free(fwnode_handle) = \
146+
device_get_next_child_node(dev, NULL); \
147+
child; child = device_get_next_child_node(dev, child))
148+
143149
struct fwnode_handle *fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
144150
const char *childname);
145151
struct fwnode_handle *device_get_named_child_node(const struct device *dev,
@@ -148,6 +154,8 @@ struct fwnode_handle *device_get_named_child_node(const struct device *dev,
148154
struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
149155
void fwnode_handle_put(struct fwnode_handle *fwnode);
150156

157+
DEFINE_FREE(fwnode_handle, struct fwnode_handle *, fwnode_handle_put(_T))
158+
151159
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
152160
int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
153161

0 commit comments

Comments
 (0)