[openib-general] slab error in kmem_cache_destroy(): cache `ib_mad': Can't free all objects

Roland Dreier roland at topspin.com
Mon May 2 13:59:14 PDT 2005


    Hal> Also, does user_mad.c leak memory on the receive side if it
    Hal> is shutdown and the application has not drained the receive
    Hal> queue ?

Yes, looks like it.  Something like this (completely untested) should
fix it, right?

 - R.

--- infiniband/core/user_mad.c	(revision 2211)
+++ infiniband/core/user_mad.c	(working copy)
@@ -499,6 +499,7 @@ static int ib_umad_open(struct inode *in
 static int ib_umad_close(struct inode *inode, struct file *filp)
 {
 	struct ib_umad_file *file = filp->private_data;
+	struct ib_umad_packet *packet, *tmp;
 	int i;
 
 	for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
@@ -507,6 +508,9 @@ static int ib_umad_close(struct inode *i
 			ib_unregister_mad_agent(file->agent[i]);
 		}
 
+	list_for_each_entry_safe(packet, tmp, &file->recv_list, list)
+		kfree(packet);
+
 	kfree(file);
 
 	return 0;



More information about the general mailing list