linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bixuan Cui <cuibixuan@huawei.com>
To: <linux-kernel@vger.kernel.org>
Cc: <maz@kernel.org>, <tglx@linutronix.de>, <john.wanghui@huawei.com>
Subject: [PATCH -next] irqdomain: fix overflow error
Date: Wed, 8 Sep 2021 09:46:23 +0800	[thread overview]
Message-ID: <20210908014623.61357-1-cuibixuan@huawei.com> (raw)

In function ‘kmalloc_node’,
    inlined from ‘kzalloc_node.constprop’ at ./include/linux/slab.h:743:9,
    inlined from ‘__irq_domain_add’ at kernel/irq/irqdomain.c:153:9:
./include/linux/slab.h:618:9: error: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
  return __kmalloc_node(size, flags, node);

The 'size' can be negative here, which will then get turned into a giant
size argument for kzalloc_node(). Changing the size to 'unsigned int'
instead seems more appropriate.

Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
 include/linux/irqdomain.h | 2 +-
 kernel/irq/irqdomain.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 23e4ee523576..9ee238ad29ce 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -251,7 +251,7 @@ static inline struct fwnode_handle *irq_domain_alloc_fwnode(phys_addr_t *pa)
 }
 
 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
-struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
+struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size,
 				    irq_hw_number_t hwirq_max, int direct_max,
 				    const struct irq_domain_ops *ops,
 				    void *host_data);
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 19e83e9b723c..4d8fc65cf38f 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -136,7 +136,7 @@ EXPORT_SYMBOL_GPL(irq_domain_free_fwnode);
  * Allocates and initializes an irq_domain structure.
  * Returns pointer to IRQ domain, or NULL on failure.
  */
-struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
+struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size,
 				    irq_hw_number_t hwirq_max, int direct_max,
 				    const struct irq_domain_ops *ops,
 				    void *host_data)
-- 
2.17.1


             reply	other threads:[~2021-09-08  1:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08  1:46 Bixuan Cui [this message]
2021-09-14 11:56 ` [PATCH -next] irqdomain: fix overflow error Thomas Gleixner
2021-09-15  2:03   ` Bixuan Cui
2021-09-15  7:49     ` Thomas Gleixner
2021-09-15  9:38       ` Bixuan Cui
2021-09-16  2:37       ` Bixuan Cui

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=20210908014623.61357-1-cuibixuan@huawei.com \
    --to=cuibixuan@huawei.com \
    --cc=john.wanghui@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).