All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging:iio:max1363: Don't free uninitialized variable
@ 2012-07-11  9:28 Lars-Peter Clausen
  2012-07-12 19:21 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Peter Clausen @ 2012-07-11  9:28 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Fengguang Wu, Lars-Peter Clausen

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>
---
 drivers/staging/iio/adc/max1363_ring.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
index bf6b0c2..774ae1b 100644
--- a/drivers/staging/iio/adc/max1363_ring.c
+++ b/drivers/staging/iio/adc/max1363_ring.c
@@ -74,7 +74,7 @@ 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();
 
@@ -82,9 +82,10 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
 		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;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging:iio:max1363: Don't free uninitialized variable
  2012-07-11  9:28 [PATCH] staging:iio:max1363: Don't free uninitialized variable Lars-Peter Clausen
@ 2012-07-12 19:21 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2012-07-12 19:21 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, Fengguang Wu

On 07/11/2012 10:28 AM, Lars-Peter Clausen wrote:
> 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>
merged to fixes-togreg and pull request sent.
> ---
>  drivers/staging/iio/adc/max1363_ring.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
> index bf6b0c2..774ae1b 100644
> --- a/drivers/staging/iio/adc/max1363_ring.c
> +++ b/drivers/staging/iio/adc/max1363_ring.c
> @@ -74,7 +74,7 @@ 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();
>  
> @@ -82,9 +82,10 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
>  		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;
>  }
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-12 19:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11  9:28 [PATCH] staging:iio:max1363: Don't free uninitialized variable Lars-Peter Clausen
2012-07-12 19:21 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.