From: Ruoyu Wang <ruoyuw560@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH] media: bt878: check register mapping in probe
Date: Sun, 7 Jun 2026 17:35:30 +0800 [thread overview]
Message-ID: <20260607093530.3-1-ruoyuw560@gmail.com> (raw)
bt878_probe() maps the device register window and then immediately clears
the interrupt mask through btwrite(). If ioremap() fails, the register
write dereferences a NULL mapping.
Check the mapping before touching the registers, and unmap it again on
later probe failures after the IRQ or DMA buffer allocation paths fail.
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/media/pci/bt8xx/bt878.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/media/pci/bt8xx/bt878.c b/drivers/media/pci/bt8xx/bt878.c
index 62a6c4a80..245a5f0ef 100644
--- a/drivers/media/pci/bt8xx/bt878.c
+++ b/drivers/media/pci/bt8xx/bt878.c
@@ -445,6 +445,10 @@ static int bt878_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
bt->bt878_mem = (unsigned char *) bt->bt878_adr;
#else
bt->bt878_mem = ioremap(bt->bt878_adr, 0x1000);
+ if (!bt->bt878_mem) {
+ result = -ENOMEM;
+ goto fail1;
+ }
#endif
/* clear interrupt mask */
@@ -486,6 +490,12 @@ static int bt878_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
fail2:
free_irq(bt->irq, bt);
fail1:
+#ifndef __sparc__
+ if (bt->bt878_mem) {
+ iounmap(bt->bt878_mem);
+ bt->bt878_mem = NULL;
+ }
+#endif
release_mem_region(pci_resource_start(bt->dev, 0),
pci_resource_len(bt->dev, 0));
fail0:
--
2.51.0
reply other threads:[~2026-06-07 9:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260607093530.3-1-ruoyuw560@gmail.com \
--to=ruoyuw560@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.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®