Commit 7b98c1c
platform/x86: thinkpad_acpi: Fix NULL pointer dereferences while probing
Some subdrivers make use of the global reference tpacpi_pdev during
initialization, which is called from the platform driver's probe.
However, after the commit 38b9ab8 ("platform/x86: thinkpad_acpi:
Move subdriver initialization to tpacpi_pdriver's probe.") this
variable is only properly initialized *after* probing and this can
result in a NULL pointer dereference.
In order to fix this without reverting the commit, register the platform
bundle in two steps, first create and initialize tpacpi_pdev, then
register the driver synchronously with platform_driver_probe(). This way
the benefits of commit 38b9ab8 are preserved.
Additionally, the commit 43fc63a ("platform/x86: thinkpad_acpi:
Move HWMON initialization to tpacpi_hwmon_pdriver's probe") introduced
a similar problem, however tpacpi_sensors_pdev is only used once inside
the probe, so replace the global reference with the one given by the
probe.
Reported-by: Damian Tometzki <[email protected]>
Closes: https://lore.kernel.org/r/CAL=B37kdL1orSQZD2A3skDOevRXBzF__cJJgY_GFh9LZO3FMsw@mail.gmail.com/
Fixes: 38b9ab8 ("platform/x86: thinkpad_acpi: Move subdriver initialization to tpacpi_pdriver's probe.")
Fixes: 43fc63a ("platform/x86: thinkpad_acpi: Move HWMON initialization to tpacpi_hwmon_pdriver's probe")
Tested-by: Damian Tometzki <[email protected]>
Tested-by: Gene C <[email protected]>
Signed-off-by: Kurt Borja <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>1 parent 0873308 commit 7b98c1c
1 file changed
+16
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
370 | 371 | | |
371 | 372 | | |
372 | 373 | | |
| |||
11820 | 11821 | | |
11821 | 11822 | | |
11822 | 11823 | | |
11823 | | - | |
| 11824 | + | |
11824 | 11825 | | |
| 11826 | + | |
11825 | 11827 | | |
11826 | | - | |
11827 | 11828 | | |
11828 | 11829 | | |
11829 | 11830 | | |
| |||
11893 | 11894 | | |
11894 | 11895 | | |
11895 | 11896 | | |
11896 | | - | |
11897 | | - | |
11898 | | - | |
| 11897 | + | |
| 11898 | + | |
11899 | 11899 | | |
11900 | 11900 | | |
11901 | 11901 | | |
| |||
11965 | 11965 | | |
11966 | 11966 | | |
11967 | 11967 | | |
11968 | | - | |
11969 | | - | |
| 11968 | + | |
| 11969 | + | |
11970 | 11970 | | |
11971 | 11971 | | |
11972 | 11972 | | |
11973 | | - | |
| 11973 | + | |
| 11974 | + | |
| 11975 | + | |
| 11976 | + | |
| 11977 | + | |
| 11978 | + | |
| 11979 | + | |
| 11980 | + | |
11974 | 11981 | | |
11975 | 11982 | | |
11976 | 11983 | | |
| 11984 | + | |
11977 | 11985 | | |
11978 | 11986 | | |
11979 | 11987 | | |
| |||
0 commit comments