From: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
To: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Al Chu <chu11-i2BcT+NCU+M@public.gmane.org>
Subject: Re: [PATCH V2] infiniband-diags/ibqueryerrors: Fix realloc size to prevent core
Date: Tue, 3 Nov 2009 16:46:52 -0800 [thread overview]
Message-ID: <20091103164652.78f1100a.weiny2@llnl.gov> (raw)
In-Reply-To: <1257284362.580.59.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
On Tue, 03 Nov 2009 13:39:22 -0800
Al Chu <chu11-i2BcT+NCU+M@public.gmane.org> wrote:
> Need to check for NULL? Manpage says its possible:
Good idea; V2 below,
Ira
From: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
Date: Tue, 3 Nov 2009 13:19:33 -0800
Subject: [PATCH] infiniband-diags/ibqueryerrors: Fix realloc size to prevent core
Realloc size was wrong causing a core when enough errors were
suppressed. Reproduced by running:
ibqueryerrors -c -s RcvSwRelayErrors,LinkDowned,VL15Dropped,XmtWait,SymbolErrors,LinkRecovers,RcvErrors
Signed-off-by: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
---
infiniband-diags/src/ibqueryerrors.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c
index f83f29e..2b5f63f 100644
--- a/infiniband-diags/src/ibqueryerrors.c
+++ b/infiniband-diags/src/ibqueryerrors.c
@@ -381,7 +381,11 @@ void print_node(ibnd_node_t * node, void *user_data)
static void add_suppressed(enum MAD_FIELDS field)
{
- suppressed_fields = realloc(suppressed_fields, sizeof(enum MAD_FIELDS));
+ suppressed_fields = realloc(suppressed_fields,
+ (sup_total+1)*sizeof(enum MAD_FIELDS));
+ if (!suppressed_fields)
+ IBERROR("realloc failed");
+
suppressed_fields[sup_total] = field;
sup_total++;
}
--
1.5.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2009-11-04 0:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-03 21:20 [PATCH] infiniband-diags/ibqueryerrors: Fix realloc size to prevent core Ira Weiny
[not found] ` <20091103132003.112e10b0.weiny2-i2BcT+NCU+M@public.gmane.org>
2009-11-03 21:39 ` Al Chu
[not found] ` <1257284362.580.59.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
2009-11-03 22:22 ` Sasha Khapyorsky
2009-11-04 0:50 ` Ira Weiny
2009-11-04 0:46 ` Ira Weiny [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=20091103164652.78f1100a.weiny2@llnl.gov \
--to=weiny2-i2bct+ncu+m@public.gmane.org \
--cc=chu11-i2BcT+NCU+M@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sashak-smomgflXvOZWk0Htik3J/w@public.gmane.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