linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] extcon: adc-jack: Fix an error handling path in 'adc_jack_probe()'
@ 2020-05-10  9:53 ` Christophe JAILLET
  2020-05-11  1:47   ` Chanwoo Choi
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2020-05-10  9:53 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, anish198519851985, gregkh, jic23, lars
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

In some error handling paths, a call to 'iio_channel_get()' is not balanced
by a corresponding call to 'iio_channel_release()'.

This can be achieved easily by using the devm_ variant of
'iio_channel_get()'.

This has the extra benefit to simplify the remove function.

Fixes: 19939860dcae ("extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch in a more complete version than commit 5a696d9760fe
("extcon: adc-jack: Release IIO channel on driver remove") which fixed the
issue for the remove function only.
---
 drivers/extcon/extcon-adc-jack.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index ad02dc6747a4..0317b614b680 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -124,7 +124,7 @@ static int adc_jack_probe(struct platform_device *pdev)
 	for (i = 0; data->adc_conditions[i].id != EXTCON_NONE; i++);
 	data->num_conditions = i;
 
-	data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
+	data->chan = devm_iio_channel_get(&pdev->dev, pdata->consumer_channel);
 	if (IS_ERR(data->chan))
 		return PTR_ERR(data->chan);
 
@@ -164,7 +164,6 @@ static int adc_jack_remove(struct platform_device *pdev)
 
 	free_irq(data->irq, data);
 	cancel_work_sync(&data->handler.work);
-	iio_channel_release(data->chan);
 
 	return 0;
 }
-- 
2.25.1


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

* Re: [PATCH] extcon: adc-jack: Fix an error handling path in 'adc_jack_probe()'
  2020-05-10  9:53 ` [PATCH] extcon: adc-jack: Fix an error handling path in 'adc_jack_probe()' Christophe JAILLET
@ 2020-05-11  1:47   ` Chanwoo Choi
  0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2020-05-11  1:47 UTC (permalink / raw)
  To: Christophe JAILLET, myungjoo.ham, anish198519851985, gregkh, jic23, lars
  Cc: linux-kernel, kernel-janitors

On 5/10/20 6:53 PM, Christophe JAILLET wrote:
> In some error handling paths, a call to 'iio_channel_get()' is not balanced
> by a corresponding call to 'iio_channel_release()'.
> 
> This can be achieved easily by using the devm_ variant of
> 'iio_channel_get()'.
> 
> This has the extra benefit to simplify the remove function.
> 
> Fixes: 19939860dcae ("extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch in a more complete version than commit 5a696d9760fe
> ("extcon: adc-jack: Release IIO channel on driver remove") which fixed the
> issue for the remove function only.
> ---
>  drivers/extcon/extcon-adc-jack.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
> index ad02dc6747a4..0317b614b680 100644
> --- a/drivers/extcon/extcon-adc-jack.c
> +++ b/drivers/extcon/extcon-adc-jack.c
> @@ -124,7 +124,7 @@ static int adc_jack_probe(struct platform_device *pdev)
>  	for (i = 0; data->adc_conditions[i].id != EXTCON_NONE; i++);
>  	data->num_conditions = i;
>  
> -	data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
> +	data->chan = devm_iio_channel_get(&pdev->dev, pdata->consumer_channel);
>  	if (IS_ERR(data->chan))
>  		return PTR_ERR(data->chan);
>  
> @@ -164,7 +164,6 @@ static int adc_jack_remove(struct platform_device *pdev)
>  
>  	free_irq(data->irq, data);
>  	cancel_work_sync(&data->handler.work);
> -	iio_channel_release(data->chan);
>  
>  	return 0;
>  }
> 

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

end of thread, other threads:[~2020-05-11  1:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200510095313epcas1p2ee698cfbe023da47555c603260fe2188@epcas1p2.samsung.com>
2020-05-10  9:53 ` [PATCH] extcon: adc-jack: Fix an error handling path in 'adc_jack_probe()' Christophe JAILLET
2020-05-11  1:47   ` Chanwoo Choi

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).