]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
thermal: int340x: Add NULL check for adev
authorChenyuan Yang <chenyuan0y@gmail.com>
Thu, 13 Mar 2025 04:36:11 +0000 (23:36 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:39:11 +0000 (14:39 +0200)
[ Upstream commit 2542a3f70e563a9e70e7ded314286535a3321bdb ]

Not all devices have an ACPI companion fwnode, so adev might be NULL.
This is similar to the commit cd2fd6eab480
("platform/x86: int3472: Check for adev == NULL").

Add a check for adev not being set and return -ENODEV in that case to
avoid a possible NULL pointer deref in int3402_thermal_probe().

Note, under the same directory, int3400_thermal_probe() has such a
check.

Fixes: 77e337c6e23e ("Thermal: introduce INT3402 thermal driver")
Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250313043611.1212116-1-chenyuan0y@gmail.com
[ rjw: Subject edit, added Fixes: ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/intel/int340x_thermal/int3402_thermal.c

index ab8bfb5a3946bc261107c95bd0466ce04d7d95c7..40ab6b2d4fb05fd04252b21f01ff189421719b2c 100644 (file)
@@ -45,6 +45,9 @@ static int int3402_thermal_probe(struct platform_device *pdev)
        struct int3402_thermal_data *d;
        int ret;
 
+       if (!adev)
+               return -ENODEV;
+
        if (!acpi_has_method(adev->handle, "_TMP"))
                return -ENODEV;