* [PATCH] PCI: fix possible null-pointer dereference about devname
@ 2022-11-21 2:00 Zeng Heng
2022-11-21 2:56 ` Bjorn Helgaas
2022-11-21 22:58 ` Bjorn Helgaas
0 siblings, 2 replies; 4+ messages in thread
From: Zeng Heng @ 2022-11-21 2:00 UTC (permalink / raw)
To: tglx, bhelgaas; +Cc: linux-pci, zengheng4, liwei391
When kvasprintf() fails to allocate memory, it would return
null-pointer. In case of null pointer dereferencing, fix it
by returning error number directly from the function.
Fixes: 704e8953d3e9 ("PCI/irq: Add pci_request_irq() and pci_free_irq() helpers")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
drivers/pci/irq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c
index 12ecd0aaa28d..0050e8f6814e 100644
--- a/drivers/pci/irq.c
+++ b/drivers/pci/irq.c
@@ -44,6 +44,8 @@ int pci_request_irq(struct pci_dev *dev, unsigned int nr, irq_handler_t handler,
va_start(ap, fmt);
devname = kvasprintf(GFP_KERNEL, fmt, ap);
va_end(ap);
+ if (!devname)
+ return -ENOMEM;
ret = request_threaded_irq(pci_irq_vector(dev, nr), handler, thread_fn,
irqflags, devname, dev_id);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: fix possible null-pointer dereference about devname
2022-11-21 2:00 [PATCH] PCI: fix possible null-pointer dereference about devname Zeng Heng
@ 2022-11-21 2:56 ` Bjorn Helgaas
2022-11-21 7:09 ` Christoph Hellwig
2022-11-21 22:58 ` Bjorn Helgaas
1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2022-11-21 2:56 UTC (permalink / raw)
To: Zeng Heng; +Cc: tglx, bhelgaas, linux-pci, liwei391, Christoph Hellwig
[+cc Christoph, 704e8953d3e9 author]
On Mon, Nov 21, 2022 at 10:00:29AM +0800, Zeng Heng wrote:
> When kvasprintf() fails to allocate memory, it would return
> null-pointer. In case of null pointer dereferencing, fix it
> by returning error number directly from the function.
>
> Fixes: 704e8953d3e9 ("PCI/irq: Add pci_request_irq() and pci_free_irq() helpers")
> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
> ---
> drivers/pci/irq.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c
> index 12ecd0aaa28d..0050e8f6814e 100644
> --- a/drivers/pci/irq.c
> +++ b/drivers/pci/irq.c
> @@ -44,6 +44,8 @@ int pci_request_irq(struct pci_dev *dev, unsigned int nr, irq_handler_t handler,
> va_start(ap, fmt);
> devname = kvasprintf(GFP_KERNEL, fmt, ap);
> va_end(ap);
> + if (!devname)
> + return -ENOMEM;
>
> ret = request_threaded_irq(pci_irq_vector(dev, nr), handler, thread_fn,
> irqflags, devname, dev_id);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: fix possible null-pointer dereference about devname
2022-11-21 2:56 ` Bjorn Helgaas
@ 2022-11-21 7:09 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-11-21 7:09 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Zeng Heng, tglx, bhelgaas, linux-pci, liwei391, Christoph Hellwig
On Sun, Nov 20, 2022 at 08:56:08PM -0600, Bjorn Helgaas wrote:
> [+cc Christoph, 704e8953d3e9 author]
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: fix possible null-pointer dereference about devname
2022-11-21 2:00 [PATCH] PCI: fix possible null-pointer dereference about devname Zeng Heng
2022-11-21 2:56 ` Bjorn Helgaas
@ 2022-11-21 22:58 ` Bjorn Helgaas
1 sibling, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2022-11-21 22:58 UTC (permalink / raw)
To: Zeng Heng; +Cc: tglx, bhelgaas, linux-pci, liwei391, Christoph Hellwig
On Mon, Nov 21, 2022 at 10:00:29AM +0800, Zeng Heng wrote:
> When kvasprintf() fails to allocate memory, it would return
> null-pointer. In case of null pointer dereferencing, fix it
> by returning error number directly from the function.
>
> Fixes: 704e8953d3e9 ("PCI/irq: Add pci_request_irq() and pci_free_irq() helpers")
> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Applied with Christoph's ack to pci/enumeration for v6.2, thanks!
> ---
> drivers/pci/irq.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c
> index 12ecd0aaa28d..0050e8f6814e 100644
> --- a/drivers/pci/irq.c
> +++ b/drivers/pci/irq.c
> @@ -44,6 +44,8 @@ int pci_request_irq(struct pci_dev *dev, unsigned int nr, irq_handler_t handler,
> va_start(ap, fmt);
> devname = kvasprintf(GFP_KERNEL, fmt, ap);
> va_end(ap);
> + if (!devname)
> + return -ENOMEM;
>
> ret = request_threaded_irq(pci_irq_vector(dev, nr), handler, thread_fn,
> irqflags, devname, dev_id);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-21 22:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21 2:00 [PATCH] PCI: fix possible null-pointer dereference about devname Zeng Heng
2022-11-21 2:56 ` Bjorn Helgaas
2022-11-21 7:09 ` Christoph Hellwig
2022-11-21 22:58 ` Bjorn Helgaas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.