kasprintf() can fail here and we must check its return value.
Arvind Yadav (4):
[PATCH 1/4] irqchip/gic-v3-its: Handle return value of kasprintf
[PATCH 2/4] irqchip/gic-v3-its-platform-msi: Handle return value of kasprintf
[PATCH 3/4] irqchip/gic: Handle return value of kasprintf
[PATCH 4/4] irqchip/lpc32xx: Handle return value of kasprintf
drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 +++
drivers/irqchip/irq-gic-v3-its-platform-msi.c | 3 +++
drivers/irqchip/irq-gic.c | 4 ++++
drivers/irqchip/irq-lpc32xx.c | 5 +++++
4 files changed, 15 insertions(+)
--
1.9.1
kasprintf() can fail here and we must check its return value.
Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
index 14a8c0a..f703069 100644
--- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
@@ -158,6 +158,9 @@ static int __init its_pci_of_msi_init(void)
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);
--
1.9.1
kasprintf() can fail here and we must check its return value.
Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/irqchip/irq-gic.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 651d726..ec4a7e6 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -1209,9 +1209,13 @@ static int __init __gic_init_bases(struct gic_chip_data *gic,
if (static_key_true(&supports_deactivate) && gic == &gic_data[0]) {
name = kasprintf(GFP_KERNEL, "GICv2");
+ if (!name)
+ return -ENOMEM;
gic_init_chip(gic, NULL, name, true);
} else {
name = kasprintf(GFP_KERNEL, "GIC-%d", (int)(gic-&gic_data[0]));
+ if (!name)
+ return -ENOMEM;
gic_init_chip(gic, NULL, name, false);
}
--
1.9.1
kasprintf() can fail here and we must check its return value.
Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/irqchip/irq-gic-v3-its-platform-msi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
index 833a90f..a731f82 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 @@ static int __init its_pmsi_init_one(struct fwnode_handle *fwnode,
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);
--
1.9.1
On Wed, Sep 20 2017 at 1:38:18 pm BST, Arvind Yadav <[email protected]> wrote:
> kasprintf() can fail here and we must check its return value.
Or not. The use of these strings is purely cosmetic (they are only used
to display various debug information), and printk is perfectly able to
handle a NULL string.
Refusing to probe an essential piece of HW because a debug feature
failed seems at best counter-productive.
Thanks,
M.
--
Jazz is not dead. It just smells funny.
Hi Marc,
On Friday 22 September 2017 01:40 PM, Marc Zyngier wrote:
> On Wed, Sep 20 2017 at 1:38:18 pm BST, Arvind Yadav <[email protected]> wrote:
>> kasprintf() can fail here and we must check its return value.
> Or not. The use of these strings is purely cosmetic (they are only used
> to display various debug information), and printk is perfectly able to
> handle a NULL string.
>
> Refusing to probe an essential piece of HW because a debug feature
> failed seems at best counter-productive.
Yes, Your are right. Sorry for noise. :)
> Thanks,
>
> M.
~arvind