Skip to content

Commit

Permalink
staging:iio:max1363: Don't free uninitialized variable
Browse files Browse the repository at this point in the history
It is possible that on one of the error paths we are going to try to free
'rxbuf', even though it has not been allocated yet, which cause the following
warning:
	drivers/staging/iio/adc/max1363_ring.c: In function 'max1363_trigger_handler':
		drivers/staging/iio/adc/max1363_ring.c:87:7: warning: 'rxbuf' may be used
		uninitialized in this function

Reported-by: Fengguang Wu <wfg@linux.intel.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Jul 12, 2012
1 parent 7b76274 commit 3879089
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/staging/iio/adc/max1363_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,18 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
else
b_sent = i2c_master_recv(st->client, rxbuf, numvals);
if (b_sent < 0)
goto done;
goto done_free;

time_ns = iio_get_time_ns();

if (indio_dev->scan_timestamp)
memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
iio_push_to_buffer(indio_dev->buffer, rxbuf, time_ns);

done_free:
kfree(rxbuf);
done:
iio_trigger_notify_done(indio_dev->trig);
kfree(rxbuf);

return IRQ_HANDLED;
}
Expand Down

0 comments on commit 3879089

Please sign in to comment.