media: budget-core: Improve exception handling in budget_register()
authorChuhong Yuan <hslester96@gmail.com>
Fri, 5 Jun 2020 16:17:28 +0000 (18:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Aug 2020 08:29:55 +0000 (10:29 +0200)
[ Upstream commit fc0456458df8b3421dba2a5508cd817fbc20ea71 ]

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

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/pci/ttpci/budget-core.c

index 97499b2af71442ffd4db39151be5252df0710d63..20524376b83be708033d73fbc4efa9fb1b738f93 100644 (file)
@@ -383,20 +383,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)