mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
77e02cf57b
The boot-time allocation interface for memblock is a mess, with
'memblock_alloc()' returning a virtual pointer, but then you are
supposed to free it with 'memblock_free()' that takes a _physical_
address.
Not only is that all kinds of strange and illogical, but it actually
causes bugs, when people then use it like a normal allocation function,
and it fails spectacularly on a NULL pointer:
https://lore.kernel.org/all/20210912140820.GD25450@xsang-OptiPlex-9020/
or just random memory corruption if the debug checks don't catch it:
https://lore.kernel.org/all/61ab2d0c-3313-aaab-514c-e15b7aa054a0@suse.cz/
I really don't want to apply patches that treat the symptoms, when the
fundamental cause is this horribly confusing interface.
I started out looking at just automating a sane replacement sequence,
but because of this mix or virtual and physical addresses, and because
people have used the "__pa()" macro that can take either a regular
kernel pointer, or just the raw "unsigned long" address, it's all quite
messy.
So this just introduces a new saner interface for freeing a virtual
address that was allocated using 'memblock_alloc()', and that was kept
as a regular kernel pointer. And then it converts a couple of users
that are obvious and easy to test, including the 'xbc_nodes' case in
lib/bootconfig.c that caused problems.
Reported-by: kernel test robot <oliver.sang@intel.com>
Fixes:
|
||
---|---|---|
.. | ||
ams | ||
adb-iop.c | ||
adb.c | ||
adbhid.c | ||
ans-lcd.c | ||
ans-lcd.h | ||
apm_emu.c | ||
Kconfig | ||
mac_hid.c | ||
macio-adb.c | ||
macio_asic.c | ||
macio_sysfs.c | ||
Makefile | ||
mediabay.c | ||
rack-meter.c | ||
smu.c | ||
therm_adt746x.c | ||
therm_windtunnel.c | ||
via-cuda.c | ||
via-macii.c | ||
via-pmu-backlight.c | ||
via-pmu-event.c | ||
via-pmu-event.h | ||
via-pmu-led.c | ||
via-pmu.c | ||
windfarm.h | ||
windfarm_ad7417_sensor.c | ||
windfarm_core.c | ||
windfarm_cpufreq_clamp.c | ||
windfarm_fcu_controls.c | ||
windfarm_lm75_sensor.c | ||
windfarm_lm87_sensor.c | ||
windfarm_max6690_sensor.c | ||
windfarm_mpu.h | ||
windfarm_pid.c | ||
windfarm_pid.h | ||
windfarm_pm72.c | ||
windfarm_pm81.c | ||
windfarm_pm91.c | ||
windfarm_pm112.c | ||
windfarm_pm121.c | ||
windfarm_rm31.c | ||
windfarm_smu_controls.c | ||
windfarm_smu_sat.c | ||
windfarm_smu_sensors.c |