intel-gpio for v6.10-2

* NULL pointer dereference fix in GPIO APCI library
 * Restore ACPI handle matching for GPIO devices represented in banks
 
 The following is an automated git shortlog grouped by driver:
 
 gpiolib:
  -  acpi: Fix failed in acpi_gpiochip_find() by adding parent node match
  -  acpi: Move ACPI device NULL check to acpi_can_fallback_to_crs()
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEqaflIX74DDDzMJJtb7wzTHR8rCgFAmZMxEgACgkQb7wzTHR8
 rCjgWQ//eT84o/XpeM+KlZpabmQBXKM7EGgVIc95gKAM77eKHNxG608DS4yxvEbU
 y+k7HDg3OZ4JFVWC7E7RTS9cImW7rxM3vbdRtymxNKZpsvT48IJeP/A0/LKV7eka
 irLX/lr+8MKM5hrwoWmO9MJrIAYA2q1JobBqQzhLaaPfz4MVhe9ntiyEZArDgSI+
 Z3F5gHVDhkfb2wtKcaUAp+OkBCmUhQPMx8hY7iZbsHCOAZtjLEGuqWbvUiL0IvEA
 X8QQ2Jfc+AkZRp5HD4PRv1jpo51O3cpv85KWmOQTzuyEzYFXoaR5pegYvRHdVCNM
 oUSheff89a7iGfSMA/v2Rpvff188gGh9PIcrKdQlk3bD2V0dTLStbbMJJBCCUcTq
 LX3CJv2RCauWexIpMXeCX+h0y4AeFbZSjoyVmMIEPUK7XGWvuGxDDMfpYz2mlo6s
 aPBuq/Wj84EWWYqLspj6yHV8mMkOoCA2K8LLinL9rev1p3d7k7CPuLW4vxLMUHH0
 CjIK8iraKt1oIsY9Ij5kqVytHUmTXYHDRXdPc32yUAVXmC0uqPvQ58AnAfWCdeQl
 Bph6eZD6ts5Xb/tGvIhw5jDovx2R1lp9/pt+2q6T/mk86xkm+/mNK9M7y3Tf5xBv
 vtjDds+OmI51Io9UKlC73cCIs3UYm8A5OeADPFLPVMuEaOQvZng=
 =/z1Z
 -----END PGP SIGNATURE-----

Merge tag 'intel-gpio-v6.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel

Pull intel-gpio fixes from Andy Shevchenko:

 - NULL pointer dereference fix in GPIO APCI library

 - Restore ACPI handle matching for GPIO devices represented in banks

* tag 'intel-gpio-v6.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel:
  gpiolib: acpi: Fix failed in acpi_gpiochip_find() by adding parent node match
  gpiolib: acpi: Move ACPI device NULL check to acpi_can_fallback_to_crs()
This commit is contained in:
Linus Torvalds 2024-05-21 11:32:02 -07:00
commit 3b1440380d

View File

@ -128,7 +128,24 @@ static bool acpi_gpio_deferred_req_irqs_done;
static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data)
{
return device_match_acpi_handle(&gc->gpiodev->dev, data);
/* First check the actual GPIO device */
if (device_match_acpi_handle(&gc->gpiodev->dev, data))
return true;
/*
* When the ACPI device is artificially split to the banks of GPIOs,
* where each of them is represented by a separate GPIO device,
* the firmware node of the physical device may not be shared among
* the banks as they may require different values for the same property,
* e.g., number of GPIOs in a certain bank. In such case the ACPI handle
* of a GPIO device is NULL and can not be used. Hence we have to check
* the parent device to be sure that there is no match before bailing
* out.
*/
if (gc->parent)
return device_match_acpi_handle(gc->parent, data);
return false;
}
/**
@ -938,6 +955,10 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
const char *con_id)
{
/* If there is no ACPI device, there is no _CRS to fall back to */
if (!adev)
return false;
/* Never allow fallback if the device has properties */
if (acpi_dev_has_props(adev) || adev->driver_gpios)
return false;
@ -978,10 +999,10 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int
}
/* Then from plain _CRS GPIOs */
if (!adev || !can_fallback)
return ERR_PTR(-ENOENT);
if (can_fallback)
return acpi_get_gpiod_by_index(adev, NULL, idx, info);
return acpi_get_gpiod_by_index(adev, NULL, idx, info);
return ERR_PTR(-ENOENT);
}
struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,