Linux-PCI Archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Duoming Zhou <duoming@zju.edu.cn>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	bhelgaas@google.com, Lizhi Hou <lizhi.hou@amd.com>,
	Rob Herring <robh@kernel.org>
Subject: Re: [PATCH] PCI: of_property: handle int_map allocation failure
Date: Thu, 2 May 2024 17:18:38 -0500	[thread overview]
Message-ID: <20240502221838.GA1550875@bhelgaas> (raw)
In-Reply-To: <20240303105729.78624-1-duoming@zju.edu.cn>

[+cc Lizhi (when you post a fix to a commit, please always cc the
author of that original commit), Rob]

On Sun, Mar 03, 2024 at 06:57:29PM +0800, Duoming Zhou wrote:
> The kcalloc() in of_pci_prop_intr_map() will return null if
> the physical memory has run out. As a result, both int_map
> and mapp will point to the null area. If we dereference mapp,
> the null pointer dereference bugs will happen.
> 
> Return -ENOMEM from of_pci_prop_intr_map() if kcalloc() fails
> for int_map.
> 
> Fixes: 407d1a51921e ("PCI: Create device tree node for bridge")
> Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>

Applied to pci/of for v6.10, thanks!

Lizhi and Rob, let me know if you have any objections.

> ---
>  drivers/pci/of_property.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
> index c2c7334152b..03539e50537 100644
> --- a/drivers/pci/of_property.c
> +++ b/drivers/pci/of_property.c
> @@ -238,6 +238,8 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
>  		return 0;
>  
>  	int_map = kcalloc(map_sz, sizeof(u32), GFP_KERNEL);
> +	if (!int_map)
> +		return -ENOMEM;
>  	mapp = int_map;
>  
>  	list_for_each_entry(child, &pdev->subordinate->devices, bus_list) {
> -- 
> 2.17.1
> 

      reply	other threads:[~2024-05-02 22:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-03 10:57 [PATCH] PCI: of_property: handle int_map allocation failure Duoming Zhou
2024-05-02 22:18 ` 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=20240502221838.GA1550875@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=duoming@zju.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lizhi.hou@amd.com \
    --cc=robh@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).