Re: [PATCH v1 1/3] i2c: i801: Fix kernel crash in is_dell_system_with_lis3lv02d()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 13 Jun 2019 19:45:27 +0300, Andy Shevchenko wrote:
> The commit
> 
>   19b07cb4a187 ("i2c: i801: Register optional lis3lv02d I2C device on Dell machines")
> 
> introduced a new check in order to enumerate some slave devices on Dell
> machines. Though, it brings a regression on machines where DMI vendor is not set.
> 
>  BUG: kernel NULL pointer dereference, address: 0000000000000000
>  #PF: supervisor read access in kernel mode
>  #PF: error_code(0x0000) - not-present page
>  PGD 0 P4D 0
>  Oops: 0000 [#1] SMP PTI
>  CPU: 8 PID: 1 Comm: swapper/0 Not tainted 5.2.0-rc4-next-20190613+ #317
>  RIP: 0010:strcmp+0xc/0x20
> 
> To fix this crash, check if vendor field is present before accessing to it.
> 
> Fixes: 19b07cb4a187 ("i2c: i801: Register optional lis3lv02d I2C device on Dell machines")

Are we certain it will be the same commit ID in the upstream kernel
tree?

> Cc: Pali Rohár <pali.rohar@xxxxxxxxx>
> Cc: Jean Delvare <jdelvare@xxxxxxx>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/i2c/busses/i2c-i801.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index 2d9f77ea02e4..694eb636b40b 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -1180,7 +1180,7 @@ static bool is_dell_system_with_lis3lv02d(void)
>  	const char *vendor;
>  
>  	vendor = dmi_get_system_info(DMI_SYS_VENDOR);
> -	if (strcmp(vendor, "Dell Inc.") != 0)
> +	if (!vendor || strcmp(vendor, "Dell Inc."))
>  		return false;
>  
>  	/*

Good catch, thanks.

Reviewed-by: Jean Delvare <jdelvare@xxxxxxx>

-- 
Jean Delvare
SUSE L3 Support



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux