<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>[openib-general] [PATCH] cache.c fixes</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Looks like allocation size is buggy and also cleanup.</FONT>
</P>
<P><FONT SIZE=2>Index: cache.c</FONT>
<BR><FONT SIZE=2>===================================================================</FONT>
<BR><FONT SIZE=2>--- cache.c (revision 1292)</FONT>
<BR><FONT SIZE=2>+++ cache.c (working copy)</FONT>
<BR><FONT SIZE=2>@@ -249,10 +249,10 @@</FONT>
</P>
<P><FONT SIZE=2> device->cache.pkey_cache =</FONT>
<BR><FONT SIZE=2> kmalloc(sizeof *device->cache.pkey_cache *</FONT>
<BR><FONT SIZE=2>- end_port(device) - start_port(device), GFP_KERNEL);</FONT>
<BR><FONT SIZE=2>+ (end_port(device) - start_port(device) + 1), GFP_KERNEL);</FONT>
<BR><FONT SIZE=2> device->cache.gid_cache =</FONT>
<BR><FONT SIZE=2> kmalloc(sizeof *device->cache.pkey_cache *</FONT>
<BR><FONT SIZE=2>- end_port(device) - start_port(device), GFP_KERNEL);</FONT>
<BR><FONT SIZE=2>+ (end_port(device) - start_port(device) + 1), GFP_KERNEL);</FONT>
</P>
<P><FONT SIZE=2> if (!device->cache.pkey_cache || !device->cache.gid_cache) {</FONT>
<BR><FONT SIZE=2> printk(KERN_WARNING "Couldn't allocate cache "</FONT>
<BR><FONT SIZE=2>@@ -280,8 +280,14 @@</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2> err:</FONT>
<BR><FONT SIZE=2>- kfree(device->cache.pkey_cache);</FONT>
<BR><FONT SIZE=2>- kfree(device->cache.gid_cache);</FONT>
<BR><FONT SIZE=2>+ if (device->cache.pkey_cache) {</FONT>
<BR><FONT SIZE=2>+ kfree(device->cache.pkey_cache);</FONT>
<BR><FONT SIZE=2>+ device->cache.pkey_cache = NULL;</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2>+ if (device->cache.gid_cache) {</FONT>
<BR><FONT SIZE=2>+ device->cache.gid_cache = NULL;</FONT>
<BR><FONT SIZE=2>+ kfree(device->cache.gid_cache);</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2> void ib_cache_cleanup_one(struct ib_device *device)</FONT>
<BR><FONT SIZE=2>@@ -296,8 +302,12 @@</FONT>
<BR><FONT SIZE=2> kfree(device->cache.gid_cache[p]);</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2>- kfree(device->cache.pkey_cache);</FONT>
<BR><FONT SIZE=2>- kfree(device->cache.gid_cache);</FONT>
<BR><FONT SIZE=2>+ if (device->cache.pkey_cache) {</FONT>
<BR><FONT SIZE=2>+ kfree(device->cache.pkey_cache);</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2>+ if (device->cache.gid_cache) {</FONT>
<BR><FONT SIZE=2>+ kfree(device->cache.gid_cache);</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2> struct ib_client cache_client = {</FONT>
</P>
</BODY>
</HTML>