linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: jic23@kernel.org
Cc: lorenzo.bianconi@redhat.com, linux-iio@vger.kernel.org,
	martin.kepplinger@puri.sm, rjones@gateworks.com
Subject: [PATCH 3/3] iio: imu: st_lsm6dsx: add sanity check for read_fifo pointer
Date: Sun, 22 Sep 2019 11:18:53 +0200	[thread overview]
Message-ID: <1af639097dd0dd01d991154dba0f3d56e3ed8333.1569143551.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1569143551.git.lorenzo@kernel.org>

Check read_fifo pointer before using it since we can't assume it
is always set adding new sensors

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index 21c2aad8c56a..f80ce77a4154 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -588,6 +588,9 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
 {
 	int err;
 
+	if (!hw->settings->fifo_ops.read_fifo)
+		return -ENOTSUPP;
+
 	mutex_lock(&hw->fifo_lock);
 
 	hw->settings->fifo_ops.read_fifo(hw);
@@ -662,6 +665,9 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private)
 	struct st_lsm6dsx_hw *hw = private;
 	int count;
 
+	if (!hw->settings->fifo_ops.read_fifo)
+		return IRQ_NONE;
+
 	mutex_lock(&hw->fifo_lock);
 	count = hw->settings->fifo_ops.read_fifo(hw);
 	mutex_unlock(&hw->fifo_lock);
-- 
2.21.0


  parent reply	other threads:[~2019-09-22  9:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-22  9:18 [PATCH 0/3] st_lsm6dsx: do not access active-low/open-drain if not supported Lorenzo Bianconi
2019-09-22  9:18 ` [PATCH 1/3] iio: imu: st_lsm6dsx: move irq related definitions in irq_config Lorenzo Bianconi
2019-09-24 13:51   ` Martin Kepplinger
2019-09-22  9:18 ` [PATCH 2/3] iio: imu: st_lsm6dsx: do not access active-low/open-drain regs if not supported Lorenzo Bianconi
2019-09-24 13:52   ` Martin Kepplinger
2019-09-24 14:07     ` Lorenzo Bianconi
2019-09-22  9:18 ` Lorenzo Bianconi [this message]
2019-09-24 13:52   ` [PATCH 3/3] iio: imu: st_lsm6dsx: add sanity check for read_fifo pointer Martin Kepplinger

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=1af639097dd0dd01d991154dba0f3d56e3ed8333.1569143551.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=martin.kepplinger@puri.sm \
    --cc=rjones@gateworks.com \
    /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).