summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorZeng Heng <zengheng4@huawei.com>2022-11-21 10:00:29 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-18 11:30:21 +0100
commit5427d904e314809065a2a1064816a054da035f06 (patch)
tree3978730fe1d2a79c2ab4df6301bf694a48e1cd16 /drivers
parent4a8087d0cc09f56f8bea7d10de1b895b4cec4bad (diff)
downloadlinux-stable-5427d904e314809065a2a1064816a054da035f06.tar.gz
linux-stable-5427d904e314809065a2a1064816a054da035f06.tar.bz2
linux-stable-5427d904e314809065a2a1064816a054da035f06.zip
PCI: Check for alloc failure in pci_request_irq()
[ Upstream commit 2d9cd957d40c3ac491b358e7cff0515bb07a3a9c ] When kvasprintf() fails to allocate memory, it returns a NULL pointer. Return error from pci_request_irq() so we don't dereference it. [bhelgaas: commit log] Fixes: 704e8953d3e9 ("PCI/irq: Add pci_request_irq() and pci_free_irq() helpers") Link: https://lore.kernel.org/r/20221121020029.3759444-1-zengheng4@huawei.com Signed-off-by: Zeng Heng <zengheng4@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/irq.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c
index a1de501a2729..3f6a5d520259 100644
--- a/drivers/pci/irq.c
+++ b/drivers/pci/irq.c
@@ -94,6 +94,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);