mbox series

[0/2] Make cb a required parameter of buffer-cb

Message ID 20201121161457.957-1-nuno.sa@analog.com (mailing list archive)
Headers show
Series Make cb a required parameter of buffer-cb | expand

Message

Nuno Sa Nov. 21, 2020, 4:14 p.m. UTC
When going through the code of the buffer-cb interface and all it's
users, I realized that the stm32_adfsdm driver is calling
`iio_channel_get_all_cb()` with NULL for the cb. After going a bit
trough the stm drivers, it looks like this is actually intentional.
However, it is clear that we have a clear/direct route here for a NULL
pointer dereference. This change makes cb a required parameter of the
API.

The first patch makes the necessary changes to the stm32_adfsdm driver
so that it does not break.

Nuno Sá (1):
  iio: buffer: Return error if no callback is given

Olivier Moysan (1):
  ASoC: stm32: dfsdm: add stm32_adfsdm_dummy_cb() callback

 drivers/iio/buffer/industrialio-buffer-cb.c |  5 +++++
 sound/soc/stm/stm32_adfsdm.c                | 12 +++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Nov. 22, 2020, 4:19 p.m. UTC | #1
On Sat, 21 Nov 2020 17:14:55 +0100
Nuno Sá <nuno.sa@analog.com> wrote:

> When going through the code of the buffer-cb interface and all it's
> users, I realized that the stm32_adfsdm driver is calling
> `iio_channel_get_all_cb()` with NULL for the cb. After going a bit
> trough the stm drivers, it looks like this is actually intentional.
> However, it is clear that we have a clear/direct route here for a NULL
> pointer dereference. This change makes cb a required parameter of the
> API.
> 
> The first patch makes the necessary changes to the stm32_adfsdm driver
> so that it does not break.

Looks good to me.  Will leave it a bit longer to let ASOC people
take a quick look at it. Give me a poke in a few weeks if it seems
like I might have lost it!

Thanks,

Jonathan

> 
> Nuno Sá (1):
>   iio: buffer: Return error if no callback is given
> 
> Olivier Moysan (1):
>   ASoC: stm32: dfsdm: add stm32_adfsdm_dummy_cb() callback
> 
>  drivers/iio/buffer/industrialio-buffer-cb.c |  5 +++++
>  sound/soc/stm/stm32_adfsdm.c                | 12 +++++++++++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
>
Jonathan Cameron Nov. 28, 2020, 1:25 p.m. UTC | #2
On Sat, 21 Nov 2020 17:14:55 +0100
Nuno Sá <nuno.sa@analog.com> wrote:

> When going through the code of the buffer-cb interface and all it's
> users, I realized that the stm32_adfsdm driver is calling
> `iio_channel_get_all_cb()` with NULL for the cb. After going a bit
> trough the stm drivers, it looks like this is actually intentional.
> However, it is clear that we have a clear/direct route here for a NULL
> pointer dereference. This change makes cb a required parameter of the
> API.
> 
> The first patch makes the necessary changes to the stm32_adfsdm driver
> so that it does not break.
> 
> Nuno Sá (1):
>   iio: buffer: Return error if no callback is given
> 
> Olivier Moysan (1):
>   ASoC: stm32: dfsdm: add stm32_adfsdm_dummy_cb() callback
> 
>  drivers/iio/buffer/industrialio-buffer-cb.c |  5 +++++
>  sound/soc/stm/stm32_adfsdm.c                | 12 +++++++++++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to do their magic.

Thanks,

Jonathan