linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: buffer: use sysfs_attr_init() on allocated attrs
@ 2021-04-02 17:42 ` Alexandru Ardelean
  2021-04-04 17:59   ` Jonathan Cameron
  2021-04-06  6:17   ` Marek Szyprowski
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandru Ardelean @ 2021-04-02 17:42 UTC (permalink / raw)
  To: linux-kernel, linux-iio; +Cc: jic23, Alexandru Ardelean, Marek Szyprowski

When dynamically allocating sysfs attributes, it's a good idea to call
sysfs_attr_init() on them to initialize lock_class_keys.
This change does that.

The lock_class_keys are set when the CONFIG_DEBUG_LOCK_ALLOC symbol is
enabled. Which is [likely] one reason why I did not see this during
development.

I also am not able to see this even with CONFIG_DEBUG_LOCK_ALLOC enabled,
so this may [likely] be reproduce-able on some system configurations.

This was reported via:
  https://lore.kernel.org/linux-iio/CA+U=DsrsvGgXEF30-vXuXS_k=-mjSjiBwEEzwKb1hJVn1P98OA@mail.gmail.com/T/#u

Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> 
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
---

@Marek: could you maybe test this on your setup?

I haven't been able to reproduce this on mine.

Thanks
Alex

 drivers/iio/industrialio-buffer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index ee5aab9d4a23..06b2ea087408 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1309,6 +1309,7 @@ static struct attribute *iio_buffer_wrap_attr(struct iio_buffer *buffer,
 	iio_attr->buffer = buffer;
 	memcpy(&iio_attr->dev_attr, dattr, sizeof(iio_attr->dev_attr));
 	iio_attr->dev_attr.attr.name = kstrdup_const(attr->name, GFP_KERNEL);
+	sysfs_attr_init(&iio_attr->dev_attr.attr);
 
 	list_add(&iio_attr->l, &buffer->buffer_attr_list);
 
-- 
2.30.2


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

* Re: [PATCH] iio: buffer: use sysfs_attr_init() on allocated attrs
  2021-04-02 17:42 ` [PATCH] iio: buffer: use sysfs_attr_init() on allocated attrs Alexandru Ardelean
@ 2021-04-04 17:59   ` Jonathan Cameron
  2021-04-06  6:17   ` Marek Szyprowski
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2021-04-04 17:59 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-kernel, linux-iio, Marek Szyprowski

On Fri,  2 Apr 2021 20:42:26 +0300
Alexandru Ardelean <aardelean@deviqon.com> wrote:

> When dynamically allocating sysfs attributes, it's a good idea to call
> sysfs_attr_init() on them to initialize lock_class_keys.
> This change does that.
> 
> The lock_class_keys are set when the CONFIG_DEBUG_LOCK_ALLOC symbol is
> enabled. Which is [likely] one reason why I did not see this during
> development.
> 
> I also am not able to see this even with CONFIG_DEBUG_LOCK_ALLOC enabled,
> so this may [likely] be reproduce-able on some system configurations.
> 
> This was reported via:
>   https://lore.kernel.org/linux-iio/CA+U=DsrsvGgXEF30-vXuXS_k=-mjSjiBwEEzwKb1hJVn1P98OA@mail.gmail.com/T/#u
> 
> Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> 
> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
> ---
> 
> @Marek: could you maybe test this on your setup?
> 
> I haven't been able to reproduce this on mine.

I'm fairly sure this is the right fix, and 'should' resolve the issue Marek
saw so I'm going to queue it up.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to poke at it and see if we missed anything.

Thanks,

Jonathan

> 
> Thanks
> Alex
> 
>  drivers/iio/industrialio-buffer.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index ee5aab9d4a23..06b2ea087408 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -1309,6 +1309,7 @@ static struct attribute *iio_buffer_wrap_attr(struct iio_buffer *buffer,
>  	iio_attr->buffer = buffer;
>  	memcpy(&iio_attr->dev_attr, dattr, sizeof(iio_attr->dev_attr));
>  	iio_attr->dev_attr.attr.name = kstrdup_const(attr->name, GFP_KERNEL);
> +	sysfs_attr_init(&iio_attr->dev_attr.attr);
>  
>  	list_add(&iio_attr->l, &buffer->buffer_attr_list);
>  


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

* Re: [PATCH] iio: buffer: use sysfs_attr_init() on allocated attrs
  2021-04-02 17:42 ` [PATCH] iio: buffer: use sysfs_attr_init() on allocated attrs Alexandru Ardelean
  2021-04-04 17:59   ` Jonathan Cameron
@ 2021-04-06  6:17   ` Marek Szyprowski
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Szyprowski @ 2021-04-06  6:17 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-kernel, linux-iio; +Cc: jic23

On 02.04.2021 19:42, Alexandru Ardelean wrote:
> When dynamically allocating sysfs attributes, it's a good idea to call
> sysfs_attr_init() on them to initialize lock_class_keys.
> This change does that.
>
> The lock_class_keys are set when the CONFIG_DEBUG_LOCK_ALLOC symbol is
> enabled. Which is [likely] one reason why I did not see this during
> development.
>
> I also am not able to see this even with CONFIG_DEBUG_LOCK_ALLOC enabled,
> so this may [likely] be reproduce-able on some system configurations.
>
> This was reported via:
>    https://lore.kernel.org/linux-iio/CA+U=DsrsvGgXEF30-vXuXS_k=-mjSjiBwEEzwKb1hJVn1P98OA@mail.gmail.com/T/#u
>
> Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
> ---
>
> @Marek: could you maybe test this on your setup?
>
> I haven't been able to reproduce this on mine.

Works fine with this fix. Thanks!

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

> Thanks
> Alex
>
>   drivers/iio/industrialio-buffer.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index ee5aab9d4a23..06b2ea087408 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -1309,6 +1309,7 @@ static struct attribute *iio_buffer_wrap_attr(struct iio_buffer *buffer,
>   	iio_attr->buffer = buffer;
>   	memcpy(&iio_attr->dev_attr, dattr, sizeof(iio_attr->dev_attr));
>   	iio_attr->dev_attr.attr.name = kstrdup_const(attr->name, GFP_KERNEL);
> +	sysfs_attr_init(&iio_attr->dev_attr.attr);
>   
>   	list_add(&iio_attr->l, &buffer->buffer_attr_list);
>   

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


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

end of thread, other threads:[~2021-04-06  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210402174237eucas1p1b117ceaf744e851703a229e87725f776@eucas1p1.samsung.com>
2021-04-02 17:42 ` [PATCH] iio: buffer: use sysfs_attr_init() on allocated attrs Alexandru Ardelean
2021-04-04 17:59   ` Jonathan Cameron
2021-04-06  6:17   ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).