linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] media: budget-core: Improve exception handling in budget_register()
@ 2020-06-05 16:17 Chuhong Yuan
  2020-06-14 20:34 ` Sean Young
  0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2020-06-05 16:17 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Markus Elfring, linux-media, linux-kernel,
	Chuhong Yuan

budget_register() has no error handling after its failure.
Add the missed undo functions for error handling to fix it.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
Changes in v2:
  - Modify the label of error handler.

 drivers/media/pci/ttpci/budget-core.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c
index fadbdeeb4495..293867b9e796 100644
--- a/drivers/media/pci/ttpci/budget-core.c
+++ b/drivers/media/pci/ttpci/budget-core.c
@@ -369,20 +369,25 @@ static int budget_register(struct budget *budget)
 	ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->hw_frontend);
 
 	if (ret < 0)
-		return ret;
+		goto err_release_dmx;
 
 	budget->mem_frontend.source = DMX_MEMORY_FE;
 	ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->mem_frontend);
 	if (ret < 0)
-		return ret;
+		goto err_release_dmx;
 
 	ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &budget->hw_frontend);
 	if (ret < 0)
-		return ret;
+		goto err_release_dmx;
 
 	dvb_net_init(&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx);
 
 	return 0;
+
+err_release_dmx:
+	dvb_dmxdev_release(&budget->dmxdev);
+	dvb_dmx_release(&budget->demux);
+	return ret;
 }
 
 static void budget_unregister(struct budget *budget)
-- 
2.26.2


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

* Re: [PATCH v2] media: budget-core: Improve exception handling in budget_register()
  2020-06-05 16:17 [PATCH v2] media: budget-core: Improve exception handling in budget_register() Chuhong Yuan
@ 2020-06-14 20:34 ` Sean Young
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Young @ 2020-06-14 20:34 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Mauro Carvalho Chehab, Markus Elfring, linux-media, linux-kernel

On Sat, Jun 06, 2020 at 12:17:28AM +0800, Chuhong Yuan wrote:
> budget_register() has no error handling after its failure.
> Add the missed undo functions for error handling to fix it.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

Changes look good, but the Fixes: points to the first import of linux
into git. I'm not sure this is useful information so I've removed it.

Applied, thanks.

> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
> Changes in v2:
>   - Modify the label of error handler.
> 
>  drivers/media/pci/ttpci/budget-core.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c
> index fadbdeeb4495..293867b9e796 100644
> --- a/drivers/media/pci/ttpci/budget-core.c
> +++ b/drivers/media/pci/ttpci/budget-core.c
> @@ -369,20 +369,25 @@ static int budget_register(struct budget *budget)
>  	ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->hw_frontend);
>  
>  	if (ret < 0)
> -		return ret;
> +		goto err_release_dmx;
>  
>  	budget->mem_frontend.source = DMX_MEMORY_FE;
>  	ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->mem_frontend);
>  	if (ret < 0)
> -		return ret;
> +		goto err_release_dmx;
>  
>  	ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &budget->hw_frontend);
>  	if (ret < 0)
> -		return ret;
> +		goto err_release_dmx;
>  
>  	dvb_net_init(&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx);
>  
>  	return 0;
> +
> +err_release_dmx:
> +	dvb_dmxdev_release(&budget->dmxdev);
> +	dvb_dmx_release(&budget->demux);
> +	return ret;
>  }
>  
>  static void budget_unregister(struct budget *budget)
> -- 
> 2.26.2

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

end of thread, other threads:[~2020-06-14 20:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 16:17 [PATCH v2] media: budget-core: Improve exception handling in budget_register() Chuhong Yuan
2020-06-14 20:34 ` Sean Young

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