All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Zeng Heng <zengheng4@huawei.com>
Cc: tglx@linutronix.de, bhelgaas@google.com,
	linux-pci@vger.kernel.org, liwei391@huawei.com,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] PCI: fix possible null-pointer dereference about devname
Date: Mon, 21 Nov 2022 16:58:10 -0600	[thread overview]
Message-ID: <20221121225810.GA141075@bhelgaas> (raw)
In-Reply-To: <20221121020029.3759444-1-zengheng4@huawei.com>

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
> 

      parent reply	other threads:[~2022-11-21 22:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20221121225810.GA141075@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=hch@lst.de \
    --cc=linux-pci@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=zengheng4@huawei.com \
    /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 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.