From: Andrey Karelin <a.karelin@ideco.ru>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrey Karelin <a.karelin@ideco.ru>,
Hans Verkuil <hverkuil+cisco@kernel.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: [PATCH 1/3] staging: media: av7110: check dvb_dmx_init() result in av7110_register()
Date: Mon, 2 Nov 2026 17:51:29 +0500 [thread overview]
Message-ID: <20261102125149.82725-2-a.karelin@ideco.ru> (raw)
In-Reply-To: <20261102125149.82725-1-a.karelin@ideco.ru>
av7110_register() ignores the return value of dvb_dmx_init() for both
the main demux and the optional budget-patch demux1. dvb_dmx_init()
fails if it cannot allocate the filter or feed arrays and leaves them
NULL, but probing continues, and the first filter or feed allocation on
that demux, e.g. when userspace sets a filter on the demux device,
dereferences the NULL array.
Check the result and fail the registration. av7110_attach() does not
call dvb_unregister() when av7110_register() fails, so add an error path
that releases everything av7110_register() has set up so far and clears
the registered flag. Use it for the existing add_frontend() and
connect_frontend() error returns as well, which leaked the demux and the
dmxdev.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Andrey Karelin <a.karelin@ideco.ru>
---
drivers/staging/media/av7110/av7110.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/media/av7110/av7110.c b/drivers/staging/media/av7110/av7110.c
index 432404eceaea..ecc15bb222c5 100644
--- a/drivers/staging/media/av7110/av7110.c
+++ b/drivers/staging/media/av7110/av7110.c
@@ -1274,7 +1274,9 @@ static int av7110_register(struct av7110 *av7110)
dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
DMX_MEMORY_BASED_FILTERING);
- dvb_dmx_init(&av7110->demux);
+ ret = dvb_dmx_init(&av7110->demux);
+ if (ret < 0)
+ goto err_registered;
av7110->demux.dmx.get_stc = dvb_get_stc;
av7110->dmxdev.filternum = (av7110->full_ts) ? 256 : 32;
@@ -1288,19 +1290,19 @@ static int av7110_register(struct av7110 *av7110)
ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
if (ret < 0)
- return ret;
+ goto err_dmxdev_release;
av7110->mem_frontend.source = DMX_MEMORY_FE;
ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
if (ret < 0)
- return ret;
+ goto err_dmxdev_release;
ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx,
&av7110->hw_frontend);
if (ret < 0)
- return ret;
+ goto err_dmxdev_release;
av7110_av_register(av7110);
av7110_ca_register(av7110);
@@ -1327,7 +1329,9 @@ static int av7110_register(struct av7110 *av7110)
dvbdemux1->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
DMX_MEMORY_BASED_FILTERING);
- dvb_dmx_init(&av7110->demux1);
+ ret = dvb_dmx_init(&av7110->demux1);
+ if (ret < 0)
+ goto err_unregister;
av7110->dmxdev1.filternum = 256;
av7110->dmxdev1.demux = &dvbdemux1->dmx;
@@ -1339,6 +1343,18 @@ static int av7110_register(struct av7110 *av7110)
pr_info("additional demux1 for budget-patch registered\n");
}
return 0;
+
+err_unregister:
+ dvb_net_release(&av7110->dvb_net);
+ dvb_unregister_device(av7110->osd_dev);
+ av7110_ca_unregister(av7110);
+ av7110_av_unregister(av7110);
+err_dmxdev_release:
+ dvb_dmxdev_release(&av7110->dmxdev);
+ dvb_dmx_release(&av7110->demux);
+err_registered:
+ av7110->registered = 0;
+ return ret;
}
static void dvb_unregister(struct av7110 *av7110)
--
2.56.0
next prev parent reply other threads:[~2026-11-02 12:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 12:51 [PATCH 0/3] staging: media: av7110: check demux and net initialization " Andrey Karelin
2026-11-02 12:51 ` Andrey Karelin [this message]
2026-11-02 12:51 ` [PATCH 2/3] staging: media: av7110: check dvb_dmxdev_init() result " Andrey Karelin
2026-11-02 12:51 ` [PATCH 3/3] staging: media: av7110: check dvb_net_init() " Andrey Karelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261102125149.82725-2-a.karelin@ideco.ru \
--to=a.karelin@ideco.ru \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=lvc-project@linuxtesting.org \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®