* [infiniband-diags] [PATCH 2/2] fix potential segfault in ibnd_node_t destroy path
@ 2009-11-06 18:14 Al Chu
[not found] ` <1257531264.18550.70.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Al Chu @ 2009-11-06 18:14 UTC (permalink / raw)
To: Sasha Khapyorsky; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 329 bytes --]
Hey Sasha,
There is a potential for the ports array in ibnd_node_t to be NULL if
you hit an error during scan and eventually destroy the fabric struct
before returning to the user.
Al
--
Albert Chu
chu11-i2BcT+NCU+M@public.gmane.org
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory
[-- Attachment #2: 0002-fix-potential-segfault-in-ibnd_node_t-destroy-path.patch --]
[-- Type: text/plain, Size: 909 bytes --]
From: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
Date: Thu, 5 Nov 2009 15:18:27 -0800
Subject: [PATCH] fix potential segfault in ibnd_node_t destroy path
Signed-off-by: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
---
infiniband-diags/libibnetdisc/src/ibnetdisc.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 62dff93..7ce9a54 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -605,10 +605,12 @@ static void destroy_node(ibnd_node_t * node)
{
int p = 0;
- for (p = 0; p <= node->numports; p++) {
- free(node->ports[p]);
+ if (node->ports) {
+ for (p = 0; p <= node->numports; p++) {
+ free(node->ports[p]);
+ }
+ free(node->ports);
}
- free(node->ports);
free(node);
}
--
1.5.4.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [infiniband-diags] [PATCH 2/2] fix potential segfault in ibnd_node_t destroy path
[not found] ` <1257531264.18550.70.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
@ 2009-11-12 23:05 ` Sasha Khapyorsky
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Khapyorsky @ 2009-11-12 23:05 UTC (permalink / raw)
To: Al Chu; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
On 10:14 Fri 06 Nov , Al Chu wrote:
> Hey Sasha,
>
> There is a potential for the ports array in ibnd_node_t to be NULL if
> you hit an error during scan and eventually destroy the fabric struct
> before returning to the user.
>
> Al
>
> --
> Albert Chu
> chu11-i2BcT+NCU+M@public.gmane.org
> Computer Scientist
> High Performance Systems Division
> Lawrence Livermore National Laboratory
> From: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
> Date: Thu, 5 Nov 2009 15:18:27 -0800
> Subject: [PATCH] fix potential segfault in ibnd_node_t destroy path
>
>
> Signed-off-by: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
Applied with minor change (see below). Thanks.
> ---
> infiniband-diags/libibnetdisc/src/ibnetdisc.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> index 62dff93..7ce9a54 100644
> --- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> +++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> @@ -605,10 +605,12 @@ static void destroy_node(ibnd_node_t * node)
> {
> int p = 0;
>
> - for (p = 0; p <= node->numports; p++) {
> - free(node->ports[p]);
> + if (node->ports) {
> + for (p = 0; p <= node->numports; p++) {
> + free(node->ports[p]);
> + }
Removing here unneeded braces around free().
Sasha
> + free(node->ports);
> }
> - free(node->ports);
> free(node);
> }
>
> --
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-12 23:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-06 18:14 [infiniband-diags] [PATCH 2/2] fix potential segfault in ibnd_node_t destroy path Al Chu
[not found] ` <1257531264.18550.70.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
2009-11-12 23:05 ` Sasha Khapyorsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox