Skip to content

Commit

Permalink
channel: don't look for attributes for iio_channel_attr_write_all
Browse files Browse the repository at this point in the history
iio_channel_attr_write_all calls iio_channel_attr_write with attr set to
NULL, causing a segmentation fault
when attr is NULL, iio_channel_find_attr is skipped

Signed-off-by: Cristina Suteu <[email protected]>
  • Loading branch information
cristina-suteu authored and pcercuei committed Sep 27, 2023
1 parent 1f48c1e commit 8e37f9f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,11 @@ ssize_t iio_channel_attr_read(const struct iio_channel *chn,
ssize_t iio_channel_attr_write_raw(const struct iio_channel *chn,
const char *attr, const void *src, size_t len)
{
attr = iio_channel_find_attr(chn, attr);
if (!attr)
return -ENOENT;
if (attr) {
attr = iio_channel_find_attr(chn, attr);
if (!attr)
return -ENOENT;
}

if (chn->dev->ctx->ops->write_channel_attr)
return chn->dev->ctx->ops->write_channel_attr(chn,
Expand Down

0 comments on commit 8e37f9f

Please sign in to comment.