From: Roel Kluin <12o3l@tiscali.nl>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org, paulus@samba.org,
lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2 v2] mpic_u3msi: mpic_u3msi: failed allocation unnoticed
Date: Thu, 24 Apr 2008 00:25:42 +0200 [thread overview]
Message-ID: <480FB766.1040405@tiscali.nl> (raw)
In-Reply-To: <df21920e067e73985f73047e2d8bcbda@kernel.crashing.org>
Segher Boessenkool wrote:
>> bitmap_find_free_region(), called by mpic_msi_alloc_hwirqs() may
>> return -ENOMEM, but hwirq of type irq_hw_number_t which is unsigned.
>
>> list_for_each_entry(entry, &pdev->msi_list, list) {
>> hwirq = mpic_msi_alloc_hwirqs(msi_mpic, 1);
>> - if (hwirq < 0) {
>> + if (hwirq == -ENOMEM) {
>
> Please test for _all_ error values, instead.
>
> Segher
In this case -ENOMEM was _all_ error values, but I get your point.
---
bitmap_find_free_region(), called by mpic_msi_alloc_hwirqs() may return
signed, but hwirq is unsigned. A failed allocation remains unnoticed.
diff --git a/arch/powerpc/sysdev/mpic_u3msi.c b/arch/powerpc/sysdev/mpic_u3msi.c
index 1d5a408..e790f39 100644
--- a/arch/powerpc/sysdev/mpic_u3msi.c
+++ b/arch/powerpc/sysdev/mpic_u3msi.c
@@ -115,14 +115,16 @@ static int u3msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
struct msi_desc *entry;
struct msi_msg msg;
u64 addr;
+ int ret;
addr = find_ht_magic_addr(pdev);
msg.address_lo = addr & 0xFFFFFFFF;
msg.address_hi = addr >> 32;
list_for_each_entry(entry, &pdev->msi_list, list) {
- hwirq = mpic_msi_alloc_hwirqs(msi_mpic, 1);
- if (hwirq < 0) {
+ ret = mpic_msi_alloc_hwirqs(msi_mpic, 1);
+ hwirq = ret;
+ if (ret < 0) {
pr_debug("u3msi: failed allocating hwirq\n");
return hwirq;
}
WARNING: multiple messages have this Message-ID (diff)
From: Roel Kluin <12o3l@tiscali.nl>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: paulus@samba.org, linuxppc-dev@ozlabs.org,
lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2 v2] mpic_u3msi: mpic_u3msi: failed allocation unnoticed
Date: Thu, 24 Apr 2008 00:25:42 +0200 [thread overview]
Message-ID: <480FB766.1040405@tiscali.nl> (raw)
In-Reply-To: <df21920e067e73985f73047e2d8bcbda@kernel.crashing.org>
Segher Boessenkool wrote:
>> bitmap_find_free_region(), called by mpic_msi_alloc_hwirqs() may
>> return -ENOMEM, but hwirq of type irq_hw_number_t which is unsigned.
>
>> list_for_each_entry(entry, &pdev->msi_list, list) {
>> hwirq = mpic_msi_alloc_hwirqs(msi_mpic, 1);
>> - if (hwirq < 0) {
>> + if (hwirq == -ENOMEM) {
>
> Please test for _all_ error values, instead.
>
> Segher
In this case -ENOMEM was _all_ error values, but I get your point.
---
bitmap_find_free_region(), called by mpic_msi_alloc_hwirqs() may return
signed, but hwirq is unsigned. A failed allocation remains unnoticed.
diff --git a/arch/powerpc/sysdev/mpic_u3msi.c b/arch/powerpc/sysdev/mpic_u3msi.c
index 1d5a408..e790f39 100644
--- a/arch/powerpc/sysdev/mpic_u3msi.c
+++ b/arch/powerpc/sysdev/mpic_u3msi.c
@@ -115,14 +115,16 @@ static int u3msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
struct msi_desc *entry;
struct msi_msg msg;
u64 addr;
+ int ret;
addr = find_ht_magic_addr(pdev);
msg.address_lo = addr & 0xFFFFFFFF;
msg.address_hi = addr >> 32;
list_for_each_entry(entry, &pdev->msi_list, list) {
- hwirq = mpic_msi_alloc_hwirqs(msi_mpic, 1);
- if (hwirq < 0) {
+ ret = mpic_msi_alloc_hwirqs(msi_mpic, 1);
+ hwirq = ret;
+ if (ret < 0) {
pr_debug("u3msi: failed allocating hwirq\n");
return hwirq;
}
next prev parent reply other threads:[~2008-04-23 22:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-23 16:51 [PATCH] powerpc: mpic_pasemi_msi: failed allocation unnoticed Roel Kluin
2008-04-23 16:54 ` [PATCH 2/2] " Roel Kluin
2008-04-23 19:00 ` [PATCH 2/2] mpic_u3msi: mpic_u3msi: " Roel Kluin
2008-04-23 22:09 ` Segher Boessenkool
2008-04-23 22:09 ` Segher Boessenkool
2008-04-23 22:25 ` Roel Kluin [this message]
2008-04-23 22:25 ` [PATCH 2/2 v2] " Roel Kluin
2008-04-23 23:03 ` Roel Kluin
2008-04-23 23:03 ` Roel Kluin
2008-04-23 23:36 ` Michael Ellerman
2008-04-23 23:36 ` Michael Ellerman
2008-04-24 0:42 ` Benjamin Herrenschmidt
2008-04-24 0:42 ` Benjamin Herrenschmidt
2008-04-23 22:32 ` [PATCH 1/2 v2] powerpc: mpic_pasemi_msi: " Roel Kluin
2008-04-23 22:32 ` Roel Kluin
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=480FB766.1040405@tiscali.nl \
--to=12o3l@tiscali.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
--cc=segher@kernel.crashing.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 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.