linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	linux-iio@vger.kernel.org,
	"Gwendal Grignou" <gwendal@chromium.org>,
	linux-kernel@vger.kernel.org,
	"Paul Cercueil" <paul@crapouillou.net>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Guenter Roeck" <groeck@chromium.org>,
	chrome-platform@lists.linux.dev,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Miaoqian Lin" <linmq006@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Alexandru Ardelean" <alexandru.ardelean@analog.com>,
	"Mihail Chindris" <mihail.chindris@analog.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Cosmin Tanislav" <cosmin.tanislav@analog.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Benson Leung" <bleung@chromium.org>,
	linux-arm-kernel@lists.infradead.org,
	"Matti Vaittinen" <matti.vaittinen@fi.rohmeurope.com>,
	"Eugen Hristev" <eugen.hristev@microchip.com>,
	"Claudiu Beznea" <claudiu.beznea@microchip.com>,
	"Jonathan Cameron" <jic23@kernel.org>
Subject: Re: [RFT PATCH v3 10/10] iio: Don't silently expect attribute types
Date: Mon, 3 Oct 2022 11:43:20 +0300	[thread overview]
Message-ID: <YzqgqERDTLVkJH67@smile.fi.intel.com> (raw)
In-Reply-To: <63f54787a684eb1232f1c5d275a09c786987fe4a.1664782676.git.mazziesaccount@gmail.com>

On Mon, Oct 03, 2022 at 11:13:53AM +0300, Matti Vaittinen wrote:
> The iio_triggered_buffer_setup_ext() and the
> devm_iio_kfifo_buffer_setup_ext() were changed by
> commit 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
> to silently expect that all attributes given in buffer_attrs array are
> device-attributes. This expectation was not forced by the API - and some
> drivers did register attributes created by IIO_CONST_ATTR().
> 
> When using IIO_CONST_ATTRs the added attribute "wrapping" does not copy
> the pointer to stored string constant and when the sysfs file is read the
> kernel will access to invalid location.
> 
> Change the function signatures to expect an array of iio_dev_attrs to
> avoid similar errors in the future.

...


Wouldn't be better to split this on per driver basis or is it impossible?

>  drivers/iio/accel/adxl367.c                          | 10 +++++-----
>  drivers/iio/accel/adxl372.c                          | 10 +++++-----
>  drivers/iio/accel/bmc150-accel-core.c                | 12 ++++++------
>  drivers/iio/adc/at91-sama5d2_adc.c                   | 12 ++++++------
>  drivers/iio/buffer/industrialio-buffer-dmaengine.c   |  4 ++--
>  drivers/iio/buffer/industrialio-triggered-buffer.c   |  4 ++--
>  drivers/iio/buffer/kfifo_buf.c                       |  2 +-
>  .../common/cros_ec_sensors/cros_ec_sensors_core.c    |  6 +++---
>  drivers/iio/common/hid-sensors/hid-sensor-trigger.c  |  8 ++++----
>  drivers/iio/industrialio-buffer.c                    | 11 +++++++----
>  include/linux/iio/buffer_impl.h                      |  2 +-
>  include/linux/iio/kfifo_buf.h                        |  3 ++-
>  include/linux/iio/triggered_buffer.h                 |  6 +++---

...

>  	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
>  	struct iio_dev_attr *p;

> +	const struct iio_dev_attr *id_attr;

I'm wondering if we may keep this upper, so "longer line goes first" rule would
be satisfied.

>  	struct attribute **attr;
>  	int ret, i, attrn, scan_el_attrcount, buffer_attrcount;
>  	const struct iio_chan_spec *channels;

...

> +		for (i = 0, id_attr = buffer->attrs[i];
> +		     (id_attr = buffer->attrs[i]); i++)

Not sure why we have additional parentheses...

> +			attr[ARRAY_SIZE(iio_buffer_attrs) + i] =
> +				(struct attribute *)&id_attr->dev_attr.attr;

...and explicit casting here. Isn't attr is already of a struct attribute?

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-10-03  8:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03  8:09 [PATCH v3 00/10] iio: Fix unsafe buffer attributes Matti Vaittinen
2022-10-03  8:11 ` [PATCH v3 04/10] iio: at91-sama5d2_adc: " Matti Vaittinen
2022-10-06  8:34   ` Claudiu.Beznea
2022-10-16 11:14     ` Jonathan Cameron
2022-10-03  8:13 ` [PATCH v3 09/10] iio: at91-sama5d2_adc: Use IIO_STATIC_CONST_DEVICE_ATTR() Matti Vaittinen
2022-10-06  8:35   ` Claudiu.Beznea
2022-10-03  8:13 ` [RFT PATCH v3 10/10] iio: Don't silently expect attribute types Matti Vaittinen
2022-10-03  8:43   ` Andy Shevchenko [this message]
2022-10-03  8:58     ` Matti Vaittinen
2022-10-03  9:02       ` Matti Vaittinen
2022-10-03  9:39         ` Andy Shevchenko
2022-10-03  9:42       ` Andy Shevchenko
2022-10-06  8:35   ` Claudiu.Beznea
2022-10-06 12:53     ` Matti Vaittinen
2022-10-09 17:38       ` Jonathan Cameron
2022-10-10  9:36         ` Matti Vaittinen
2022-11-05 14:45           ` Jonathan Cameron

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=YzqgqERDTLVkJH67@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=claudiu.beznea@microchip.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=eugen.hristev@microchip.com \
    --cc=groeck@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linmq006@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mazziesaccount@gmail.com \
    --cc=mihail.chindris@analog.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=nathan@kernel.org \
    --cc=paul@crapouillou.net \
    --cc=u.kleine-koenig@pengutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).