linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/5] iio: pressure: bmp280: Tolerate IRQ before registering
@ 2020-03-23 10:41 Andy Shevchenko
  2020-03-23 10:41 ` [PATCH v2 2/5] iio: pressure: bmp280: Convert to use ->read_avail() Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-03-23 10:41 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: Andy Shevchenko, Linus Walleij

With DEBUG_SHIRQ enabled we have a kernel crash

[  116.482696] BUG: kernel NULL pointer dereference, address: 0000000000000000

...

[  116.606571] Call Trace:
[  116.609023]  <IRQ>
[  116.611047]  complete+0x34/0x50
[  116.614206]  bmp085_eoc_irq+0x9/0x10 [bmp280]

because DEBUG_SHIRQ mechanism fires an IRQ before registration and drivers
ought to be able to handle an interrupt happening before request_irq() returns.

Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt")
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: put conditional logic back when re-initializing completion (Jonathan)
 drivers/iio/pressure/bmp280-core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 29c209cc1108..2540e7c2358c 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -713,7 +713,7 @@ static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas)
 	unsigned int ctrl;
 
 	if (data->use_eoc)
-		init_completion(&data->done);
+		reinit_completion(&data->done);
 
 	ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas);
 	if (ret)
@@ -969,6 +969,9 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
 			"trying to enforce it\n");
 		irq_trig = IRQF_TRIGGER_RISING;
 	}
+
+	init_completion(&data->done);
+
 	ret = devm_request_threaded_irq(dev,
 			irq,
 			bmp085_eoc_irq,
-- 
2.25.1


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

end of thread, other threads:[~2020-03-28 16:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 10:41 [PATCH v2 1/5] iio: pressure: bmp280: Tolerate IRQ before registering Andy Shevchenko
2020-03-23 10:41 ` [PATCH v2 2/5] iio: pressure: bmp280: Convert to use ->read_avail() Andy Shevchenko
2020-03-23 10:41 ` [PATCH v2 3/5] iio: pressure: bmp280: Explicitly mark GPIO optional Andy Shevchenko
2020-03-23 10:41 ` [PATCH v2 4/5] iio: pressure: bmp280: Drop unneeded explicit castings Andy Shevchenko
2020-03-23 10:41 ` [PATCH v2 5/5] iio: pressure: bmp280: Join string literals back Andy Shevchenko
2020-03-27 10:50 ` [PATCH v2 1/5] iio: pressure: bmp280: Tolerate IRQ before registering Linus Walleij
2020-03-28 16:02   ` Jonathan Cameron

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).