Skip to content

Commit ec6badf

Browse files
committed
Merge tag 'acpi-5.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fixes from Rafael Wysocki: "These fix a recently broken Kconfig dependency and ACPI device reference counting in an iterator macro. Specifics: - Fix recently broken Kconfig dependency for the ACPI table override via built-in initrd (Robert Richter) - Fix ACPI device reference counting in the for_each_acpi_dev_match() helper macro to avoid use-after-free (Andy Shevchenko)" * tag 'acpi-5.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: utils: Fix reference counting in for_each_acpi_dev_match() ACPI: Kconfig: Fix table override from built-in initrd
2 parents 1d59768 + 0b8a53a commit ec6badf

File tree

5 files changed

+6
-15
lines changed

5 files changed

+6
-15
lines changed

drivers/acpi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ config ACPI_TABLE_UPGRADE
370370
config ACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD
371371
bool "Override ACPI tables from built-in initrd"
372372
depends on ACPI_TABLE_UPGRADE
373-
depends on INITRAMFS_SOURCE!="" && INITRAMFS_COMPRESSION=""
373+
depends on INITRAMFS_SOURCE!="" && INITRAMFS_COMPRESSION_NONE
374374
help
375375
This option provides functionality to override arbitrary ACPI tables
376376
from built-in uncompressed initrd.

drivers/acpi/utils.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,9 @@ EXPORT_SYMBOL(acpi_dev_present);
860860
* Return the next match of ACPI device if another matching device was present
861861
* at the moment of invocation, or NULL otherwise.
862862
*
863-
* FIXME: The function does not tolerate the sudden disappearance of @adev, e.g.
864-
* in the case of a hotplug event. That said, the caller should ensure that
865-
* this will never happen.
866-
*
867863
* The caller is responsible for invoking acpi_dev_put() on the returned device.
864+
* On the other hand the function invokes acpi_dev_put() on the given @adev
865+
* assuming that its reference counter had been increased beforehand.
868866
*
869867
* See additional information in acpi_dev_present() as well.
870868
*/
@@ -880,6 +878,7 @@ acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const cha
880878
match.hrv = hrv;
881879

882880
dev = bus_find_device(&acpi_bus_type, start, &match, acpi_dev_match_cb);
881+
acpi_dev_put(adev);
883882
return dev ? to_acpi_device(dev) : NULL;
884883
}
885884
EXPORT_SYMBOL(acpi_dev_get_next_match_dev);

drivers/firmware/efi/dev-path-parser.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
3434
break;
3535
if (!adev->pnp.unique_id && node->acpi.uid == 0)
3636
break;
37-
acpi_dev_put(adev);
3837
}
3938
if (!adev)
4039
return -ENODEV;

drivers/media/pci/intel/ipu3/cio2-bridge.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,8 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
173173
int ret;
174174

175175
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
176-
if (!adev->status.enabled) {
177-
acpi_dev_put(adev);
176+
if (!adev->status.enabled)
178177
continue;
179-
}
180178

181179
if (bridge->n_sensors >= CIO2_NUM_PORTS) {
182180
acpi_dev_put(adev);
@@ -185,7 +183,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
185183
}
186184

187185
sensor = &bridge->sensors[bridge->n_sensors];
188-
sensor->adev = adev;
189186
strscpy(sensor->name, cfg->hid, sizeof(sensor->name));
190187

191188
ret = cio2_bridge_read_acpi_buffer(adev, "SSDB",
@@ -215,6 +212,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
215212
goto err_free_swnodes;
216213
}
217214

215+
sensor->adev = acpi_dev_get(adev);
218216
adev->fwnode.secondary = fwnode;
219217

220218
dev_info(&cio2->dev, "Found supported sensor %s\n",

include/acpi/acpi_bus.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,6 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
707707
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV
708708
*
709709
* The caller is responsible for invoking acpi_dev_put() on the returned device.
710-
*
711-
* FIXME: Due to above requirement there is a window that may invalidate @adev
712-
* and next iteration will use a dangling pointer, e.g. in the case of a
713-
* hotplug event. That said, the caller should ensure that this will never
714-
* happen.
715710
*/
716711
#define for_each_acpi_dev_match(adev, hid, uid, hrv) \
717712
for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv); \

0 commit comments

Comments
 (0)