[openib-general] [PATCH] cache.c fixes
Eli Cohen
eli at mellanox.co.il
Thu Nov 25 04:36:30 PST 2004
Looks like allocation size is buggy and also cleanup.
Index: cache.c
===================================================================
--- cache.c (revision 1292)
+++ cache.c (working copy)
@@ -249,10 +249,10 @@
device->cache.pkey_cache =
kmalloc(sizeof *device->cache.pkey_cache *
- end_port(device) - start_port(device), GFP_KERNEL);
+ (end_port(device) - start_port(device) + 1), GFP_KERNEL);
device->cache.gid_cache =
kmalloc(sizeof *device->cache.pkey_cache *
- end_port(device) - start_port(device), GFP_KERNEL);
+ (end_port(device) - start_port(device) + 1), GFP_KERNEL);
if (!device->cache.pkey_cache || !device->cache.gid_cache) {
printk(KERN_WARNING "Couldn't allocate cache "
@@ -280,8 +280,14 @@
}
err:
- kfree(device->cache.pkey_cache);
- kfree(device->cache.gid_cache);
+ if (device->cache.pkey_cache) {
+ kfree(device->cache.pkey_cache);
+ device->cache.pkey_cache = NULL;
+ }
+ if (device->cache.gid_cache) {
+ device->cache.gid_cache = NULL;
+ kfree(device->cache.gid_cache);
+ }
}
void ib_cache_cleanup_one(struct ib_device *device)
@@ -296,8 +302,12 @@
kfree(device->cache.gid_cache[p]);
}
- kfree(device->cache.pkey_cache);
- kfree(device->cache.gid_cache);
+ if (device->cache.pkey_cache) {
+ kfree(device->cache.pkey_cache);
+ }
+ if (device->cache.gid_cache) {
+ kfree(device->cache.gid_cache);
+ }
}
struct ib_client cache_client = {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20041125/84369129/attachment.html>
More information about the general
mailing list