From: Markus Elfring <Markus.Elfring@web.de>
To: Wang Jun <1742789905@qq.com>,
linux-media@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org, gszhai@bjtu.edu.cn,
23120469@bjtu.edu.cn, 25125332@bjtu.edu.cn, 25125283@bjtu.edu.cn
Subject: Re: [PATCH v3] media: saa7164: add missing ioremap error handling
Date: Thu, 12 Mar 2026 16:28:13 +0100 [thread overview]
Message-ID: <a44adff7-60fd-4fca-85f4-0c69a035ec69@web.de> (raw)
In-Reply-To: <tencent_D591461D8821B2B10E09549FF5379CE6C706@qq.com>
> Add checks for ioremap return values in saa7164_dev_setup(). If
> ioremap for BAR0 or BAR2 fails, release the already allocated PCI
> memory regions, remove the device from the global list, decrement
> the device count, and return -ENODEV.
See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc3#n659
> This prevents potential null pointer dereferences and ensures proper
> cleanup on memory mapping failures.
How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc3#n145
…
> +++ b/drivers/media/pci/saa7164/saa7164-core.c
> @@ -998,9 +998,21 @@ static int saa7164_dev_setup(struct saa7164_dev *dev)
> /* PCI/e allocations */
> dev->lmmio = ioremap(pci_resource_start(dev->pci, 0),
> pci_resource_len(dev->pci, 0));
> + if (!dev->lmmio) {
> + dev_err(&dev->pci->dev,
> + "failed to remap MMIO memory @ 0x%llx\n",
> + (u64)pci_resource_start(dev->pci, 0));
> + goto err_ioremap;
> + }
>
> dev->lmmio2 = ioremap(pci_resource_start(dev->pci, 2),
> pci_resource_len(dev->pci, 2));
…
Would you like to avoid duplicate source code here?
…
> @@ -1019,6 +1031,23 @@ static int saa7164_dev_setup(struct saa7164_dev *dev)
> saa7164_pci_quirks(dev);
>
> return 0;
…
> + /* Remove from device list and decrement count */
> + mutex_lock(&devlist);
> + list_del(&dev->devlist);
> + mutex_unlock(&devlist);
> + saa7164_devcount--;
…
Will development interests grow to apply a call like “scoped_guard(mutex, &devlist)”?
https://elixir.bootlin.com/linux/v7.0-rc3/source/include/linux/mutex.h#L253
Regards,
Markus
parent reply other threads:[~2026-03-12 15:28 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <tencent_D591461D8821B2B10E09549FF5379CE6C706@qq.com>]
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=a44adff7-60fd-4fca-85f4-0c69a035ec69@web.de \
--to=markus.elfring@web.de \
--cc=1742789905@qq.com \
--cc=23120469@bjtu.edu.cn \
--cc=25125283@bjtu.edu.cn \
--cc=25125332@bjtu.edu.cn \
--cc=gszhai@bjtu.edu.cn \
--cc=kernel-janitors@vger.kernel.org \
--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