mirror of
https://github.com/torvalds/linux.git
synced 2026-07-29 02:31:27 +02:00
spi: Add NULL check for spi_get_device_id() in spi_get_device_match_data()
Prevent NULL pointer dereference when spi_get_device_id() returns NULL, which can happen when using driver_override without matching SPI ID entry. Signed-off-by: guoqi0226 <guoqi0226@163.com> Link: https://patch.msgid.link/20260616103018.105612-3-guoqi0226@163.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f846d68992
commit
f1b061b4d4
|
|
@ -355,12 +355,16 @@ EXPORT_SYMBOL_GPL(spi_get_device_id);
|
|||
const void *spi_get_device_match_data(const struct spi_device *sdev)
|
||||
{
|
||||
const void *match;
|
||||
const struct spi_device_id *id;
|
||||
|
||||
match = device_get_match_data(&sdev->dev);
|
||||
if (match)
|
||||
return match;
|
||||
|
||||
return (const void *)spi_get_device_id(sdev)->driver_data;
|
||||
id = spi_get_device_id(sdev);
|
||||
if (!id)
|
||||
return NULL;
|
||||
return (const void *)id->driver_data;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spi_get_device_match_data);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user