All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: imu: st_lsm6dsx: use dev_to_iio_dev() to get iio_dev struct
@ 2022-02-24 11:29 haibo.chen
  2022-02-26 18:19 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: haibo.chen @ 2022-02-24 11:29 UTC (permalink / raw)
  To: lorenzo.bianconi83, jic23, lars; +Cc: linux-iio, haibo.chen, linux-imx

From: Haibo Chen <haibo.chen@nxp.com>

After commit 8b7651f25962 ("iio: iio_device_alloc(): Remove
unnecessary self drvdata"), current driver will meet kernel dump,
kernel handle NULL pointer dereference.

Use dev_to_iio_dev() to get iio_dev struct.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 93f0c6bce502..b1d8d5a66f01 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -1633,7 +1633,7 @@ st_lsm6dsx_sysfs_sampling_frequency_avail(struct device *dev,
 					  struct device_attribute *attr,
 					  char *buf)
 {
-	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev));
+	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_to_iio_dev(dev));
 	const struct st_lsm6dsx_odr_table_entry *odr_table;
 	int i, len = 0;
 
@@ -1651,7 +1651,7 @@ static ssize_t st_lsm6dsx_sysfs_scale_avail(struct device *dev,
 					    struct device_attribute *attr,
 					    char *buf)
 {
-	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev));
+	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_to_iio_dev(dev));
 	const struct st_lsm6dsx_fs_table_entry *fs_table;
 	struct st_lsm6dsx_hw *hw = sensor->hw;
 	int i, len = 0;
-- 
2.25.1


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

* Re: [PATCH] iio: imu: st_lsm6dsx: use dev_to_iio_dev() to get iio_dev struct
  2022-02-24 11:29 [PATCH] iio: imu: st_lsm6dsx: use dev_to_iio_dev() to get iio_dev struct haibo.chen
@ 2022-02-26 18:19 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-02-26 18:19 UTC (permalink / raw)
  To: haibo.chen; +Cc: lorenzo.bianconi83, lars, linux-iio, linux-imx

On Thu, 24 Feb 2022 19:29:51 +0800
haibo.chen@nxp.com wrote:

> From: Haibo Chen <haibo.chen@nxp.com>
> 
> After commit 8b7651f25962 ("iio: iio_device_alloc(): Remove
> unnecessary self drvdata"), current driver will meet kernel dump,
> kernel handle NULL pointer dereference.
Formal Fixes tag needed, but I can turn this into one whilst applying
and modify this description to talk about what no longer works rather
than the patch.
> 
> Use dev_to_iio_dev() to get iio_dev struct.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Looks correct to me, so I'll queue it up in the iio/fixes-togreg branch.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 93f0c6bce502..b1d8d5a66f01 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -1633,7 +1633,7 @@ st_lsm6dsx_sysfs_sampling_frequency_avail(struct device *dev,
>  					  struct device_attribute *attr,
>  					  char *buf)
>  {
> -	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev));
> +	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_to_iio_dev(dev));
>  	const struct st_lsm6dsx_odr_table_entry *odr_table;
>  	int i, len = 0;
>  
> @@ -1651,7 +1651,7 @@ static ssize_t st_lsm6dsx_sysfs_scale_avail(struct device *dev,
>  					    struct device_attribute *attr,
>  					    char *buf)
>  {
> -	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev));
> +	struct st_lsm6dsx_sensor *sensor = iio_priv(dev_to_iio_dev(dev));
>  	const struct st_lsm6dsx_fs_table_entry *fs_table;
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
>  	int i, len = 0;


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

end of thread, other threads:[~2022-02-26 18:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-24 11:29 [PATCH] iio: imu: st_lsm6dsx: use dev_to_iio_dev() to get iio_dev struct haibo.chen
2022-02-26 18:19 ` Jonathan Cameron

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.