All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io: imu: st_lsm6dsx: check if dev is null pointer
@ 2021-10-08  3:21 Jiasheng Jiang
  2021-10-08  7:49 ` Lorenzo Bianconi
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2021-10-08  3:21 UTC (permalink / raw)
  To: lorenzo.bianconi83, jic23, lars; +Cc: linux-iio, linux-kernel, Jiasheng Jiang

The parameter 'dev' of st_lsm6dsx_probe() isn't been
checked before used, including when st_lsm6dsx_probe() is called.
Therefore, it might be better to check, just in case.

Fixes: 290a6ce ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 7cedaab..7b4754d 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2199,6 +2199,8 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 	const char *name = NULL;
 	int i, err;
 
+	if (!dev)
+		return -ENOMEM;
 	hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
 	if (!hw)
 		return -ENOMEM;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] io: imu: st_lsm6dsx: check if dev is null pointer
  2021-10-08  3:21 [PATCH] io: imu: st_lsm6dsx: check if dev is null pointer Jiasheng Jiang
@ 2021-10-08  7:49 ` Lorenzo Bianconi
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Bianconi @ 2021-10-08  7:49 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: lorenzo.bianconi83, jic23, lars, linux-iio

[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]

> The parameter 'dev' of st_lsm6dsx_probe() isn't been
> checked before used, including when st_lsm6dsx_probe() is called.
> Therefore, it might be better to check, just in case.
> 
> Fixes: 290a6ce ("iio: imu: add support to lsm6dsx driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 7cedaab..7b4754d 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2199,6 +2199,8 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  	const char *name = NULL;
>  	int i, err;
>  
> +	if (!dev)
> +		return -ENOMEM;

can this really happen? dev is a structure (not a pointer) in i2c_client or
spi_device.

Regards,
Lorenzo

>  	hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
>  	if (!hw)
>  		return -ENOMEM;
> -- 
> 2.7.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-08  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08  3:21 [PATCH] io: imu: st_lsm6dsx: check if dev is null pointer Jiasheng Jiang
2021-10-08  7:49 ` Lorenzo Bianconi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.