Skip to contentSkip to conversation

iio: Fix uninitialized variable ret

PATCH In review Colin King 2 participants 2 messages Oct 15, 2021 – Oct 17, 2021

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 iio: Fix uninitialized variable ret

From: Colin Ian King <[email protected]>

When !iio_buffer_space_available(rb) is true and signal_pending(current) is false the end of the do-while loop is reached and the uninitialized variable ret is zero checked. Fix this by initializing variable ret to zero.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes ffabbffd40f2 ("iio: Add output buffer support")
---
 drivers/iio/industrialio-buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/industrialio-buffer.c +1 -1
index b884d78657cb..c97fb8462395 100644
@@ -179,7 +179,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,
 	struct iio_buffer *rb = ib->buffer;
 	struct iio_dev *indio_dev = ib->indio_dev;
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
-	int ret;
+	int ret = 0;
 	size_t written;
 
 	if (!indio_dev->info)
Signature · 1 line
2.32.0
maintainer
#1 lore raw
Quoted 10 lines · On Fri, 15 Oct 2021 16:32:54 +0100 Colin King <[email protected]> wrote:

From: Colin Ian King <[email protected]>

When !iio_buffer_space_available(rb) is true and signal_pending(current) is false the end of the do-while loop is reached and the uninitialized variable ret is zero checked. Fix this by initializing variable ret to zero.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes ffabbffd40f2 ("iio: Add output buffer support")

Looks like the correct fix to me. If anyone disagrees shout soon!

Applied to the iio-togreg branch of iio.git and pushed out as testing for 0-day to poke at it.

Jonathan

Quoted 17 lines
---
 drivers/iio/industrialio-buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/industrialio-buffer.c +1 -1
index b884d78657cb..c97fb8462395 100644
@@ -179,7 +179,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,
 	struct iio_buffer *rb = ib->buffer;
 	struct iio_dev *indio_dev = ib->indio_dev;
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
-	int ret;
+	int ret = 0;
 	size_t written;
 
 	if (!indio_dev->info)