mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
platform/mellanox: mlxbf-pmc: Check ACPI_COMPANION() against NULL
Every platform driver can be forced to match a device that doesn't match
its list of device IDs because of device_match_driver_override(), so
platform drivers that rely on the existence of a device's ACPI companion
object need to verify its presence.
mlxbf_pmc_probe() passes the result of ACPI_COMPANION() to
acpi_device_hid(), which dereferences it, so force-binding the driver to
a device without an ACPI companion leads to a NULL pointer dereference.
Accordingly, add a requisite ACPI_COMPANION() check against NULL to the
mlxbf-pmc driver and return -ENODEV when the companion is missing.
Fixes: 1a218d312e ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Link: https://patch.msgid.link/20260706012056.524096-1-lilinmao@kylinos.cn
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
ef3daa2b84
commit
c38cce70ad
|
|
@ -2262,13 +2262,19 @@ static int mlxbf_pmc_map_counters(struct device *dev)
|
|||
|
||||
static int mlxbf_pmc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev);
|
||||
const char *hid = acpi_device_hid(acpi_dev);
|
||||
struct device *dev = &pdev->dev;
|
||||
struct acpi_device *acpi_dev;
|
||||
struct arm_smccc_res res;
|
||||
const char *hid;
|
||||
guid_t guid;
|
||||
int ret;
|
||||
|
||||
acpi_dev = ACPI_COMPANION(&pdev->dev);
|
||||
if (!acpi_dev)
|
||||
return -ENODEV;
|
||||
|
||||
hid = acpi_device_hid(acpi_dev);
|
||||
|
||||
/* Ensure we have the UUID we expect for this service. */
|
||||
arm_smccc_smc(MLXBF_PMC_SIP_SVC_UID, 0, 0, 0, 0, 0, 0, 0, &res);
|
||||
guid_parse(mlxbf_pmc_svc_uuid_str, &guid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user