patch "iio: common: st_sensors: fix possible infinite loop in" added to staging-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
iio: common: st_sensors: fix possible infinite loop in
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 40c48fb79b9798954691f24b8ece1d3a7eb1b353 Mon Sep 17 00:00:00 2001
From: Lorenzo Bianconi <[email protected]>
Date: Tue, 8 Dec 2020 15:36:40 +0100
Subject: iio: common: st_sensors: fix possible infinite loop in
st_sensors_irq_thread
Return a boolean value in st_sensors_new_samples_available routine in order to avoid an infinite loop in st_sensors_irq_thread if stat_drdy.addr is not defined or stat_drdy read fails
--- .../common/st_sensors/st_sensors_trigger.c | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/iio/common/st_sensors/st_sensors_trigger.c +17 -14
@@ -23,35 +23,31 @@* @sdata: Sensor data. * * returns: -* 0 - no new samples available -* 1 - new samples available -* negative - error or unknown +* false - no new samples available or read error +* true - new samples available */ -static int st_sensors_new_samples_available (struct iio_dev *indio_dev, -struct st_sensor_data *sdata) +static bool st_sensors_new_samples_available (struct iio_dev *indio_dev, +struct st_sensor_data *sdata) {int ret, status;/* How would I know if I can't check it? */ if (!sdata->sensor_settings->drdy_irq.stat_drdy.addr) -return -EINVAL ; +return true;/* No scan mask, no interrupt */ if (!indio_dev->active_scan_mask) -return 0 ; +return false; ret =regmap_read (sdata->regmap, sdata->sensor_settings->drdy_irq.stat_drdy.addr, &status);if (ret <0 ) {dev_err (sdata->dev,"error checking samples available\n" ); -return ret; +return false; } -if (status & sdata->sensor_settings->drdy_irq.stat_drdy.mask) -return 1 ; - -return 0 ; +return !!(status & sdata->sensor_settings->drdy_irq.stat_drdy.mask); }/**
@@ -180,9 +176,15 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,/* Tell the interrupt handler that we're dealing with edges */ if (irq_trig ==IRQF_TRIGGER_FALLING || - irq_trig ==IRQF_TRIGGER_RISING ) + irq_trig ==IRQF_TRIGGER_RISING ) { +if (!sdata->sensor_settings->drdy_irq.stat_drdy.addr) { +dev_err (&indio_dev->dev, +"edge IRQ not supported w/o stat register.\n" ); + err = -EOPNOTSUPP ; + goto iio_trigger_free; + } sdata->edge_irq = true; -else + }else {/* * If we're not using edges (i.e. level interrupts) we * just mask off the IRQ, handle one interrupt, then
@@ -190,6 +192,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,* interrupt handler top half again and start over. */ irq_trig |=IRQF_ONESHOT ; + }/* * If the interrupt pin is Open Drain, by definition this
Signature · 1 line
2.30.0