Merge tag 'gpio-fixes-for-v7.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: - propagate the error code from regulator_enable() in resume path in gpio-pca953x - take the device lock when calling device_is_bound() in virtual GPIO drivers - fix software node leak in remove path in gpio-aggregator - fix a potential use-after-free in gpio-aggregator - harden the GPIO character device uAPI: check that line config attributes are correctly zeroed * tag 'gpio-fixes-for-v7.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: virtuser: lock device when calling device_is_bound() gpio: aggregator: lock device when calling device_is_bound() gpio: sim: lock device when calling device_is_bound() gpio: aggregator: remove the software node when deactivating the aggregator gpio: aggregator: fix a potential use-after-free gpio: cdev: check if uAPI v2 config attributes are correctly zeroed gpio: pca953x: propagate regulator_enable() error from resume
This commit is contained in:
commit
99e08debac
5 files changed
+38
-12
No files matched your search
@@ -968,9 +968,12 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
|
||||
}
|
||||
|
||||
wait_for_device_probe();
|
||||
if (!device_is_bound(&pdev->dev)) {
|
||||
ret = -ENXIO;
|
||||
goto err_unregister_pdev;
|
||||
|
||||
scoped_guard(device, &pdev->dev) {
|
||||
if (!device_is_bound(&pdev->dev)) {
|
||||
ret = -ENXIO;
|
||||
goto err_unregister_pdev;
|
||||
}
|
||||
}
|
||||
|
||||
aggr->pdev = pdev;
|
||||
@@ -979,8 +982,8 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
|
||||
err_unregister_pdev:
|
||||
platform_device_unregister(pdev);
|
||||
err_remove_lookup_table:
|
||||
kfree(aggr->lookups->dev_id);
|
||||
gpiod_remove_lookup_table(aggr->lookups);
|
||||
kfree(aggr->lookups->dev_id);
|
||||
err_remove_swnode:
|
||||
fwnode_remove_software_node(swnode);
|
||||
err_remove_lookups:
|
||||
@@ -991,11 +994,15 @@ err_remove_lookups:
|
||||
|
||||
static void gpio_aggregator_deactivate(struct gpio_aggregator *aggr)
|
||||
{
|
||||
struct fwnode_handle *swnode;
|
||||
|
||||
swnode = dev_fwnode(&aggr->pdev->dev);
|
||||
platform_device_unregister(aggr->pdev);
|
||||
aggr->pdev = NULL;
|
||||
gpiod_remove_lookup_table(aggr->lookups);
|
||||
kfree(aggr->lookups->dev_id);
|
||||
kfree(aggr->lookups);
|
||||
fwnode_remove_software_node(swnode);
|
||||
}
|
||||
|
||||
static void gpio_aggregator_lockup_configfs(struct gpio_aggregator *aggr,
|
||||
|
||||
@@ -1411,7 +1411,7 @@ static int pca953x_resume(struct device *dev)
|
||||
ret = regulator_enable(chip->regulator);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to enable regulator: %d\n", ret);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -901,7 +901,7 @@ static int gpio_sim_device_activate(struct gpio_sim_device *dev)
|
||||
struct platform_device *pdev;
|
||||
struct fwnode_handle *swnode;
|
||||
struct gpio_sim_bank *bank;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
lockdep_assert_held(&dev->lock);
|
||||
|
||||
@@ -945,9 +945,12 @@ static int gpio_sim_device_activate(struct gpio_sim_device *dev)
|
||||
}
|
||||
|
||||
wait_for_device_probe();
|
||||
if (!device_is_bound(&pdev->dev)) {
|
||||
ret = -ENXIO;
|
||||
goto err_unregister_pdev;
|
||||
|
||||
scoped_guard(device, &pdev->dev) {
|
||||
if (!device_is_bound(&pdev->dev)) {
|
||||
ret = -ENXIO;
|
||||
goto err_unregister_pdev;
|
||||
}
|
||||
}
|
||||
|
||||
dev->pdev = pdev;
|
||||
|
||||
@@ -1477,9 +1477,12 @@ gpio_virtuser_device_activate(struct gpio_virtuser_device *dev)
|
||||
}
|
||||
|
||||
wait_for_device_probe();
|
||||
if (!device_is_bound(&pdev->dev)) {
|
||||
ret = -ENXIO;
|
||||
goto err_unregister_pdev;
|
||||
|
||||
scoped_guard(device, &pdev->dev) {
|
||||
if (!device_is_bound(&pdev->dev)) {
|
||||
ret = -ENXIO;
|
||||
goto err_unregister_pdev;
|
||||
}
|
||||
}
|
||||
|
||||
dev->pdev = pdev;
|
||||
|
||||
@@ -1184,6 +1184,7 @@ static int gpio_v2_line_flags_validate(u64 flags)
|
||||
static int gpio_v2_line_config_validate(struct gpio_v2_line_config *lc,
|
||||
unsigned int num_lines)
|
||||
{
|
||||
size_t unused_attrs;
|
||||
unsigned int i;
|
||||
u64 flags;
|
||||
int ret;
|
||||
@@ -1191,9 +1192,21 @@ static int gpio_v2_line_config_validate(struct gpio_v2_line_config *lc,
|
||||
if (lc->num_attrs > GPIO_V2_LINE_NUM_ATTRS_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
unused_attrs = GPIO_V2_LINE_NUM_ATTRS_MAX - lc->num_attrs;
|
||||
|
||||
if (!mem_is_zero(lc->padding, sizeof(lc->padding)))
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < lc->num_attrs; i++) {
|
||||
if (lc->attrs[i].attr.padding != 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (unused_attrs) {
|
||||
if (!mem_is_zero(&lc->attrs[lc->num_attrs], unused_attrs * sizeof(*lc->attrs)))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_lines; i++) {
|
||||
flags = gpio_v2_line_config_flags(lc, i);
|
||||
ret = gpio_v2_line_flags_validate(flags);
|
||||
|
||||
Reference in new issue
Block a user