u-boot/drivers/core
Simon Glass 24fd7e383d dm: core: Fix allocation of empty of-platdata
With of-platdata we always have a dtv struct that holds the platform data
provided by the driver_info record. However, this struct can be empty if
there are no actual devicetree properties provided.

The upshot of empty platform data is that it will end up as a zero-size
member in the BSS section, which is fine. But if the driver specifies
plat_auto then it expects the correct amount of space to be allocated.

At present this does not happen, since device_bind() assumes that the
platform-data size will always be >0. As a result we end up not
allocating the space and just use the BSS region, overwriting whatever
other contents are present.

Fix this by removing the condition that platform data be non-empty, always
allocating space if requested.

This fixes a strange bug that has been lurking since of-platdata was
implemented. It has likely never been noticed since devices normally have
at least some devicetree properties, BSS is seldom used on SPL, the dtv
structs are normally at the end of bss and the overwriting only happens
if a driver changes its platform data.

It was discovered using sandbox_spl, which exercises more features than
a normal board might, and the critical global_data variable 'gd' happened
to be at the end of BSS.

Fixes: 9fa2819009 ("dm: core: Expand platdata for of-platdata devices")
Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-03 19:17:25 -07:00
..
acpi.c dm: treewide: Rename ofdata_to_platdata() to of_to_plat() 2020-12-13 16:51:09 -07:00
device-remove.c Merge branch '2021-02-02-drop-asm_global_data-when-unused' 2021-02-15 10:16:45 -05:00
device.c dm: core: Fix allocation of empty of-platdata 2021-03-03 19:17:25 -07:00
devres.c dm: core: Access device flags through functions 2021-01-05 12:24:41 -07:00
dump.c dm: core: Access device flags through functions 2021-01-05 12:24:41 -07:00
fdtaddr.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
Kconfig dm: Introduce DMA constraints into the core device model 2021-02-18 11:56:25 +01:00
lists.c dm: core: Add logging when lists_bind_fdt() fails 2021-01-05 12:24:41 -07:00
Makefile dm: Avoid using #ifdef for CONFIG_OF_LIVE 2020-10-29 14:42:17 -06:00
of_access.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
of_addr.c dm: Introduce xxx_get_dma_range() 2021-02-18 11:56:25 +01:00
of_extra.c dm: core: Update ofnode_read_fmap_entry() to read hashes 2021-01-30 14:25:42 -07:00
ofnode.c dm: Introduce xxx_get_dma_range() 2021-02-18 11:56:25 +01:00
read.c dm: Introduce xxx_get_dma_range() 2021-02-18 11:56:25 +01:00
read_extra.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
regmap.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
root.c Merge branch '2021-02-02-drop-asm_global_data-when-unused' 2021-02-15 10:16:45 -05:00
simple-bus.c dm: core: Move priv/plat structs for simple_bus to headers 2021-01-05 12:24:41 -07:00
simple-pm-bus.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
syscon-uclass.c dm: treewide: Rename ..._platdata variables to just ..._plat 2020-12-13 16:51:09 -07:00
uclass.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
util.c dm: core: Allow dm_warn() to be used in SPL 2020-10-29 14:42:17 -06:00