Re: [RFC PATCH 1/1] iio: buffer: Sanity check buffer callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/12/20 4:13 PM, Nuno Sá wrote:
Make sure that a callback is actually present before trying to call
it...

Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
  drivers/iio/buffer/industrialio-buffer-cb.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
index 47c96f7f4976..b4385f59399d 100644
--- a/drivers/iio/buffer/industrialio-buffer-cb.c
+++ b/drivers/iio/buffer/industrialio-buffer-cb.c
@@ -27,6 +27,10 @@ static struct iio_cb_buffer *buffer_to_cb_buffer(struct iio_buffer *buffer)
  static int iio_buffer_cb_store_to(struct iio_buffer *buffer, const void *data)
  {
  	struct iio_cb_buffer *cb_buff = buffer_to_cb_buffer(buffer);
+
+	if (!cb_buff->cb)
+		return 0;
+
I think it makes more sense to check this once when the buffer is registered instead of every time we want to call the function.



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux