Skip to content

Commit

Permalink
Merge tag 'acpi-5.14-rc3' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/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
  • Loading branch information
Linus Torvalds committed Jul 23, 2021
2 parents 1d59768 + 0b8a53a commit ec6badf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ config ACPI_TABLE_UPGRADE
config ACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD
bool "Override ACPI tables from built-in initrd"
depends on ACPI_TABLE_UPGRADE
depends on INITRAMFS_SOURCE!="" && INITRAMFS_COMPRESSION=""
depends on INITRAMFS_SOURCE!="" && INITRAMFS_COMPRESSION_NONE
help
This option provides functionality to override arbitrary ACPI tables
from built-in uncompressed initrd.
Expand Down
7 changes: 3 additions & 4 deletions drivers/acpi/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,11 +860,9 @@ EXPORT_SYMBOL(acpi_dev_present);
* Return the next match of ACPI device if another matching device was present
* at the moment of invocation, or NULL otherwise.
*
* FIXME: The function does not tolerate the sudden disappearance of @adev, e.g.
* in the case of a hotplug event. That said, the caller should ensure that
* this will never happen.
*
* The caller is responsible for invoking acpi_dev_put() on the returned device.
* On the other hand the function invokes acpi_dev_put() on the given @adev
* assuming that its reference counter had been increased beforehand.
*
* See additional information in acpi_dev_present() as well.
*/
Expand All @@ -880,6 +878,7 @@ acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const cha
match.hrv = hrv;

dev = bus_find_device(&acpi_bus_type, start, &match, acpi_dev_match_cb);
acpi_dev_put(adev);
return dev ? to_acpi_device(dev) : NULL;
}
EXPORT_SYMBOL(acpi_dev_get_next_match_dev);
Expand Down
1 change: 0 additions & 1 deletion drivers/firmware/efi/dev-path-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
break;
if (!adev->pnp.unique_id && node->acpi.uid == 0)
break;
acpi_dev_put(adev);
}
if (!adev)
return -ENODEV;
Expand Down
6 changes: 2 additions & 4 deletions drivers/media/pci/intel/ipu3/cio2-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,8 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
int ret;

for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
if (!adev->status.enabled) {
acpi_dev_put(adev);
if (!adev->status.enabled)
continue;
}

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

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

ret = cio2_bridge_read_acpi_buffer(adev, "SSDB",
Expand Down Expand Up @@ -215,6 +212,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
goto err_free_swnodes;
}

sensor->adev = acpi_dev_get(adev);
adev->fwnode.secondary = fwnode;

dev_info(&cio2->dev, "Found supported sensor %s\n",
Expand Down
5 changes: 0 additions & 5 deletions include/acpi/acpi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,6 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV
*
* The caller is responsible for invoking acpi_dev_put() on the returned device.
*
* FIXME: Due to above requirement there is a window that may invalidate @adev
* and next iteration will use a dangling pointer, e.g. in the case of a
* hotplug event. That said, the caller should ensure that this will never
* happen.
*/
#define for_each_acpi_dev_match(adev, hid, uid, hrv) \
for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv); \
Expand Down

0 comments on commit ec6badf

Please sign in to comment.