Linux IIO development
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: lorenzo.bianconi83@gmail.com, jic23@kernel.org, lars@metafoo.de,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH] io: imu: st_lsm6dsx: check if dev is null pointer
Date: Fri, 8 Oct 2021 09:49:27 +0200	[thread overview]
Message-ID: <YV/4B3mSn5ejJcgr@localhost.localdomain> (raw)
In-Reply-To: <1633663260-71997-1-git-send-email-jiasheng@iscas.ac.cn>

[-- 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 --]

      reply	other threads:[~2021-10-08  7:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YV/4B3mSn5ejJcgr@localhost.localdomain \
    --to=lorenzo@kernel.org \
    --cc=jiasheng@iscas.ac.cn \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox