From: YueHaibing <yuehaibing@huawei.com>
To: <tglx@linutronix.de>, <jason@lakedaemon.net>, <marc.zyngier@arm.com>
Cc: <linux-kernel@vger.kernel.org>, YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH] irqchip/gic-v3: check kasprintf() for failures
Date: Tue, 24 Apr 2018 15:10:36 +0800 [thread overview]
Message-ID: <20180424071036.20188-1-yuehaibing@huawei.com> (raw)
We should just return -ENOMEM here if the allocation fails,
otherwise it may cause a panic.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 +++
drivers/irqchip/irq-gic-v3-its-platform-msi.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
index 25a98de..ef3911f 100644
--- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
@@ -160,6 +160,9 @@ its_pci_msi_parse_madt(struct acpi_subtable_header *header,
its_entry = (struct acpi_madt_generic_translator *)header;
node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx",
(long)its_entry->base_address);
+ if(!node_name)
+ return -ENOMEM;
+
dom_handle = iort_find_domain_token(its_entry->translation_id);
if (!dom_handle) {
pr_err("%s: Unable to locate ITS domain handle\n", node_name);
diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
index 8881a05..b676fb4 100644
--- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
@@ -126,6 +126,9 @@ its_pmsi_parse_madt(struct acpi_subtable_header *header,
its_entry = (struct acpi_madt_generic_translator *)header;
node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx",
(long)its_entry->base_address);
+ if(!node_name)
+ return -ENOMEM;
+
domain_handle = iort_find_domain_token(its_entry->translation_id);
if (!domain_handle) {
pr_err("%s: Unable to locate ITS domain handle\n", node_name);
--
2.7.0
next reply other threads:[~2018-04-24 7:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-24 7:10 YueHaibing [this message]
2018-04-24 7:21 ` Marc Zyngier
2018-04-24 7:45 ` YueHaibing
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=20180424071036.20188-1-yuehaibing@huawei.com \
--to=yuehaibing@huawei.com \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®