libibumad: fix freeing wrong memory on failure
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 21 Jan 2010 06:08:38 +0000 (06:08 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 21 Jan 2010 06:08:38 +0000 (06:08 +0000)
umad_get_ca() should free the allocated 'ports' memory on failure,
not the ca structure, which is provided by the user.

Bug reported by Leonid Keller.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2671 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/libibumad/src/umad.cpp

index 62473e3..8fd70b1 100644 (file)
@@ -221,6 +221,7 @@ int umad_get_ca(char *ca_name, umad_ca_t *ca)
 \r
                ret = umad_query_port(context, ca->ports[i]);\r
                if (ret != 0) {\r
+                       delete ports;\r
                        goto close;\r
                }\r
        }\r
@@ -229,9 +230,6 @@ close:
        ibv_close_device(context);\r
 free:\r
        ibv_free_device_list(list);\r
-       if (ret != 0) {\r
-               delete ca;\r
-       }\r
        return ret;\r
 }\r
 \r