IB/umad: fix memory leaks
authorJack Morgenstein <jackm@mellanox.co.il>
Fri, 9 Dec 2005 21:46:32 +0000 (13:46 -0800)
committerRoland Dreier <rolandd@cisco.com>
Fri, 9 Dec 2005 21:46:32 +0000 (13:46 -0800)
Don't leak packet if it had a timeout, and don't leak timeout struct
if queue_packet() fails.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/user_mad.c

index eb7f52537ccc9c41faa51d787ecd9b0a73cec894..c908de8db5a9b1201e825684039dca3bd75dd55f 100644 (file)
@@ -197,8 +197,8 @@ static void send_handler(struct ib_mad_agent *agent,
                memcpy(timeout->mad.data, packet->mad.data,
                       sizeof (struct ib_mad_hdr));
 
-               if (!queue_packet(file, agent, timeout))
-                               return;
+               if (queue_packet(file, agent, timeout))
+                       kfree(timeout);
        }
 out:
        kfree(packet);