WSL2-Linux-Kernel/drivers/fsi
Christophe JAILLET 72c4f4200f fsi: Aspeed: Fix a potential double free
[ Upstream commit 83ba7e895d ]

A struct device can never be devm_alloc()'ed.
Here, it is embedded in "struct fsi_master", and "struct fsi_master" is
embedded in "struct fsi_master_aspeed".

Since "struct device" is embedded, the data structure embedding it must be
released with the release function, as is already done here.

So use kzalloc() instead of devm_kzalloc() when allocating "aspeed" and
update all error handling branches accordingly.

This prevent a potential double free().

This also fix another issue if opb_readl() fails. Instead of a direct
return, it now jumps in the error handling path.

Fixes: 606397d67f ("fsi: Add ast2600 master driver")
Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Suggested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/2c123f8b0a40dc1a061fae982169fe030b4f47e6.1641765339.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-08 14:23:44 +02:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile fsi: Add ast2600 master driver 2019-11-08 11:28:20 +01:00
cf-fsi-fw.h fsi: cf-fsi-fw: Use the correct style for SPDX License Identifier 2019-06-19 19:35:51 +02:00
fsi-core.c fsi: core: Fix return of error values on failures 2021-06-04 14:11:48 +09:30
fsi-master-aspeed.c fsi: Aspeed: Fix a potential double free 2022-04-08 14:23:44 +02:00
fsi-master-ast-cf.c fsi: master-ast-cf: Remove redundant error printing in fsi_master_acf_probe() 2021-06-04 15:02:55 +09:30
fsi-master-gpio.c fsi: Add missing MODULE_DEVICE_TABLE 2021-06-04 14:10:45 +09:30
fsi-master-hub.c fsi: master: Constify hub_master_ids 2020-09-10 12:22:50 +09:30
fsi-master.h fsi: master: Add boolean parameter to link_enable function 2020-09-10 12:22:47 +09:30
fsi-occ.c fsi: occ: Log error for checksum failure 2021-06-04 14:29:57 +09:30
fsi-sbefifo.c fsi/sbefifo: Fix reset timeout 2021-06-04 16:06:57 +09:30
fsi-scom.c fsi: scom: Remove retries in indirect scoms 2022-04-08 14:23:44 +02:00