[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YgHKekl9rJ2jH5j4@shinobu>
Date: Tue, 8 Feb 2022 10:42:18 +0900
From: William Breathitt Gray <vilhelm.gray@...il.com>
To: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Cc: linux-iio@...r.kernel.org,
Robin van der Gracht <robin@...tonic.nl>,
linux-kernel@...r.kernel.org,
Oleksij Rempel <o.rempel@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
David Jander <david@...tonic.nl>,
Jonathan Cameron <jic23@...nel.org>
Subject: Re: [PATCH] counter: Stop using dev_get_drvdata() to get the counter
device
On Fri, Feb 04, 2022 at 09:25:56AM +0100, Uwe Kleine-König wrote:
> dev_get_drvdata() returns NULL since commit b56346ddbd82 ("counter: Use
> container_of instead of drvdata to track counter_device") which wrongly
> claimed there were no users of drvdata. Convert to container_of() to
> fix a null pointer dereference.
>
> Reported-by: Oleksij Rempel <o.rempel@...gutronix.de>
> Fixes: b56346ddbd82 ("counter: Use container_of instead of drvdata to track counter_device")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
I'll pick this up and apply it to my tree.
Thanks,
William Breathitt Gray
> ---
> drivers/counter/counter-sysfs.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
> index 7cc4d1d523ea..04eac41dad33 100644
> --- a/drivers/counter/counter-sysfs.c
> +++ b/drivers/counter/counter-sysfs.c
> @@ -19,6 +19,11 @@
>
> #include "counter-sysfs.h"
>
> +static inline struct counter_device *counter_from_dev(struct device *dev)
> +{
> + return container_of(dev, struct counter_device, dev);
> +}
> +
> /**
> * struct counter_attribute - Counter sysfs attribute
> * @dev_attr: device attribute for sysfs
> @@ -90,7 +95,7 @@ static ssize_t counter_comp_u8_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> const struct counter_attribute *const a = to_counter_attribute(attr);
> - struct counter_device *const counter = dev_get_drvdata(dev);
> + struct counter_device *const counter = counter_from_dev(dev);
> int err;
> u8 data = 0;
>
> @@ -122,7 +127,7 @@ static ssize_t counter_comp_u8_store(struct device *dev,
> const char *buf, size_t len)
> {
> const struct counter_attribute *const a = to_counter_attribute(attr);
> - struct counter_device *const counter = dev_get_drvdata(dev);
> + struct counter_device *const counter = counter_from_dev(dev);
> int err;
> bool bool_data = 0;
> u8 data = 0;
> @@ -158,7 +163,7 @@ static ssize_t counter_comp_u32_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> const struct counter_attribute *const a = to_counter_attribute(attr);
> - struct counter_device *const counter = dev_get_drvdata(dev);
> + struct counter_device *const counter = counter_from_dev(dev);
> const struct counter_available *const avail = a->comp.priv;
> int err;
> u32 data = 0;
> @@ -221,7 +226,7 @@ static ssize_t counter_comp_u32_store(struct device *dev,
> const char *buf, size_t len)
> {
> const struct counter_attribute *const a = to_counter_attribute(attr);
> - struct counter_device *const counter = dev_get_drvdata(dev);
> + struct counter_device *const counter = counter_from_dev(dev);
> struct counter_count *const count = a->parent;
> struct counter_synapse *const synapse = a->comp.priv;
> const struct counter_available *const avail = a->comp.priv;
> @@ -281,7 +286,7 @@ static ssize_t counter_comp_u64_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> const struct counter_attribute *const a = to_counter_attribute(attr);
> - struct counter_device *const counter = dev_get_drvdata(dev);
> + struct counter_device *const counter = counter_from_dev(dev);
> int err;
> u64 data = 0;
>
> @@ -309,7 +314,7 @@ static ssize_t counter_comp_u64_store(struct device *dev,
> const char *buf, size_t len)
> {
> const struct counter_attribute *const a = to_counter_attribute(attr);
> - struct counter_device *const counter = dev_get_drvdata(dev);
> + struct counter_device *const counter = counter_from_dev(dev);
> int err;
> u64 data = 0;
>
>
> base-commit: e783362eb54cd99b2cac8b3a9aeac942e6f6ac07
> --
> 2.34.1
>
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists