linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] drivers:iio:accel:mma8452: added cleanup provision in case of failure.
@ 2016-07-04 10:08 Bijosh Thykkoottathil
  2016-07-04 12:20 ` Martin Kepplinger
  0 siblings, 1 reply; 4+ messages in thread
From: Bijosh Thykkoottathil @ 2016-07-04 10:08 UTC (permalink / raw)
  To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de,
	pmeerw@pmeerw.net, martink@posteo.de,
	christoph.muellner@theobroma-systems.com
  Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org

mma8452_set_freefall_mode can return -ve value in case if
i2c_smbus_read_byte_data fails. This function is called from mma8452_probe,
and returning -ve value from probe indicates probe failure. Need to call
iio_triggered_buffer_cleanup & iio_trigger_cleanup in this case.

Signed-off-by: Bijosh Thykkoottathil <bijosh.t@hotmail.com>
---
 drivers/iio/accel/mma8452.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index e225d3c..1bcf5c3 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1444,8 +1444,8 @@ static int mma8452_probe(struct i2c_client *client,
 		goto buffer_cleanup;
=20
 	ret =3D mma8452_set_freefall_mode(data, false);
-	if (ret)
-		return ret;
+	if (ret < 0)
+		goto buffer_cleanup;
=20
 	return 0;
=20
--=20
2.1.4

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

* Re: [PATCH v1] drivers:iio:accel:mma8452: added cleanup provision in case of failure.
  2016-07-04 10:08 [PATCH v1] drivers:iio:accel:mma8452: added cleanup provision in case of failure Bijosh Thykkoottathil
@ 2016-07-04 12:20 ` Martin Kepplinger
  2016-07-05 20:02   ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Kepplinger @ 2016-07-04 12:20 UTC (permalink / raw)
  To: Bijosh Thykkoottathil, jic23@kernel.org, knaack.h@gmx.de,
	lars@metafoo.de, pmeerw@pmeerw.net,
	christoph.muellner@theobroma-systems.com
  Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org

Am 2016-07-04 um 12:08 schrieb Bijosh Thykkoottathil:
> mma8452_set_freefall_mode can return -ve value in case if
> i2c_smbus_read_byte_data fails. This function is called from mma8452_probe,
> and returning -ve value from probe indicates probe failure. Need to call
> iio_triggered_buffer_cleanup & iio_trigger_cleanup in this case.

Thanks for your review, nice catch! Looks good to me. You just could
have said "Don't leak allocated buffer on error during probe().", but oh
well :)

> 
> Signed-off-by: Bijosh Thykkoottathil <bijosh.t@hotmail.com>
Reviewed-by: Martin Kepplinger <martink@posteo.de>

> ---
>  drivers/iio/accel/mma8452.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index e225d3c..1bcf5c3 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -1444,8 +1444,8 @@ static int mma8452_probe(struct i2c_client *client,
>  		goto buffer_cleanup;
>  
>  	ret = mma8452_set_freefall_mode(data, false);
> -	if (ret)
> -		return ret;
> +	if (ret < 0)
> +		goto buffer_cleanup;
>  
>  	return 0;
>  
> 

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

* Re: [PATCH v1] drivers:iio:accel:mma8452: added cleanup provision in case of failure.
  2016-07-04 12:20 ` Martin Kepplinger
@ 2016-07-05 20:02   ` Jonathan Cameron
  2016-07-05 20:06     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2016-07-05 20:02 UTC (permalink / raw)
  To: Martin Kepplinger, Bijosh Thykkoottathil, knaack.h@gmx.de,
	lars@metafoo.de, pmeerw@pmeerw.net,
	christoph.muellner@theobroma-systems.com
  Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org

On 04/07/16 13:20, Martin Kepplinger wrote:
> Am 2016-07-04 um 12:08 schrieb Bijosh Thykkoottathil:
>> mma8452_set_freefall_mode can return -ve value in case if
>> i2c_smbus_read_byte_data fails. This function is called from mma8452_probe,
>> and returning -ve value from probe indicates probe failure. Need to call
>> iio_triggered_buffer_cleanup & iio_trigger_cleanup in this case.
> 
> Thanks for your review, nice catch! Looks good to me. You just could
> have said "Don't leak allocated buffer on error during probe().", but oh
> well :)
> 
>>
>> Signed-off-by: Bijosh Thykkoottathil <bijosh.t@hotmail.com>
> Reviewed-by: Martin Kepplinger <martink@posteo.de>
Applied, thanks.

Jonathan
> 
>> ---
>>  drivers/iio/accel/mma8452.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
>> index e225d3c..1bcf5c3 100644
>> --- a/drivers/iio/accel/mma8452.c
>> +++ b/drivers/iio/accel/mma8452.c
>> @@ -1444,8 +1444,8 @@ static int mma8452_probe(struct i2c_client *client,
>>  		goto buffer_cleanup;
>>  
>>  	ret = mma8452_set_freefall_mode(data, false);
>> -	if (ret)
>> -		return ret;
>> +	if (ret < 0)
>> +		goto buffer_cleanup;
>>  
>>  	return 0;
>>  
>>


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

* Re: [PATCH v1] drivers:iio:accel:mma8452: added cleanup provision in case of failure.
  2016-07-05 20:02   ` Jonathan Cameron
@ 2016-07-05 20:06     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2016-07-05 20:06 UTC (permalink / raw)
  To: Martin Kepplinger, Bijosh Thykkoottathil, knaack.h@gmx.de,
	lars@metafoo.de, pmeerw@pmeerw.net,
	christoph.muellner@theobroma-systems.com
  Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org

On 05/07/16 21:02, Jonathan Cameron wrote:
> On 04/07/16 13:20, Martin Kepplinger wrote:
>> Am 2016-07-04 um 12:08 schrieb Bijosh Thykkoottathil:
>>> mma8452_set_freefall_mode can return -ve value in case if
>>> i2c_smbus_read_byte_data fails. This function is called from mma8452_probe,
>>> and returning -ve value from probe indicates probe failure. Need to call
>>> iio_triggered_buffer_cleanup & iio_trigger_cleanup in this case.
>>
>> Thanks for your review, nice catch! Looks good to me. You just could
>> have said "Don't leak allocated buffer on error during probe().", but oh
>> well :)
>>
>>>
>>> Signed-off-by: Bijosh Thykkoottathil <bijosh.t@hotmail.com>
>> Reviewed-by: Martin Kepplinger <martink@posteo.de>
> Applied, thanks.
Flipped this one over to an Acked-by as well for same reason
as the other patch though even more so here!
> 
> Jonathan
>>
>>> ---
>>>  drivers/iio/accel/mma8452.c | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
>>> index e225d3c..1bcf5c3 100644
>>> --- a/drivers/iio/accel/mma8452.c
>>> +++ b/drivers/iio/accel/mma8452.c
>>> @@ -1444,8 +1444,8 @@ static int mma8452_probe(struct i2c_client *client,
>>>  		goto buffer_cleanup;
>>>  
>>>  	ret = mma8452_set_freefall_mode(data, false);
>>> -	if (ret)
>>> -		return ret;
>>> +	if (ret < 0)
>>> +		goto buffer_cleanup;
>>>  
>>>  	return 0;
>>>  
>>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

end of thread, other threads:[~2016-07-05 20:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-04 10:08 [PATCH v1] drivers:iio:accel:mma8452: added cleanup provision in case of failure Bijosh Thykkoottathil
2016-07-04 12:20 ` Martin Kepplinger
2016-07-05 20:02   ` Jonathan Cameron
2016-07-05 20:06     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).