--- initial
+++ final
@@ -1,118 +1,118 @@
 static int proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) {
   const int tmpsiz = 256;
   struct lnet_peer_table *ptable;
   char *tmpstr;
   char *s;
   int cpt = LNET_PROC_CPT_GET(*ppos);
   int ver = LNET_PROC_VER_GET(*ppos);
   int hash = LNET_PROC_HASH_GET(*ppos);
   int hoff = LNET_PROC_HOFF_GET(*ppos);
   int rc = 0;
   int len;
   BUILD_BUG_ON(LNET_PROC_HASH_BITS < LNET_PEER_HASH_BITS);
   LASSERT(!write);
   if (!*lenp) return 0;
   if (cpt >= LNET_CPT_NUMBER) {
     *lenp = 0;
     return 0;
   }
-  LIBCFS_ALLOC(tmpstr, tmpsiz);
+  tmpstr = kmalloc(tmpsiz, GFP_NOFS);
   if (!tmpstr) return -ENOMEM;
   s = tmpstr; /* points to current position in tmpstr[] */
   if (!*ppos) {
     s += snprintf(s, tmpstr + tmpsiz - s, "%-24s %4s %5s %5s %5s %5s %5s %5s %5s %s\n", "nid", "refs", "state", "last", "max", "rtr", "min", "tx", "min", "queue");
     LASSERT(tmpstr + tmpsiz - s > 0);
     hoff++;
   } else {
     struct lnet_peer *peer;
     struct list_head *p;
     int skip;
   again:
     p = NULL;
     peer = NULL;
     skip = hoff - 1;
     lnet_net_lock(cpt);
     ptable = the_lnet.ln_peer_tables[cpt];
     if (hoff == 1) ver = LNET_PROC_VERSION(ptable->pt_version);
     if (ver != LNET_PROC_VERSION(ptable->pt_version)) {
       lnet_net_unlock(cpt);
-      LIBCFS_FREE(tmpstr, tmpsiz);
+      kfree(tmpstr);
       return -ESTALE;
     }
     while (hash < LNET_PEER_HASH_SIZE) {
       if (!p) p = ptable->pt_hash[hash].next;
       while (p != &ptable->pt_hash[hash]) {
         struct lnet_peer *lp;
         lp = list_entry(p, struct lnet_peer, lp_hashlist);
         if (!skip) {
           peer = lp;
           /*
            * minor optimization: start from idx+1
            * on next iteration if we've just
            * drained lp_hashlist
            */
           if (lp->lp_hashlist.next == &ptable->pt_hash[hash]) {
             hoff = 1;
             hash++;
           } else {
             hoff++;
           }
           break;
         }
         skip--;
         p = lp->lp_hashlist.next;
       }
       if (peer) break;
       p = NULL;
       hoff = 1;
       hash++;
     }
     if (peer) {
       lnet_nid_t nid = peer->lp_nid;
       int nrefs = peer->lp_refcount;
       int lastalive = -1;
       char *aliveness = "NA";
       int maxcr = peer->lp_ni->ni_peertxcredits;
       int txcr = peer->lp_txcredits;
       int mintxcr = peer->lp_mintxcredits;
       int rtrcr = peer->lp_rtrcredits;
       int minrtrcr = peer->lp_minrtrcredits;
       int txqnob = peer->lp_txqnob;
       if (lnet_isrouter(peer) || lnet_peer_aliveness_enabled(peer)) aliveness = peer->lp_alive ? "up" : "down";
       if (lnet_peer_aliveness_enabled(peer)) {
         unsigned long now = cfs_time_current();
         long delta;
         delta = cfs_time_sub(now, peer->lp_last_alive);
         lastalive = cfs_duration_sec(delta);
         /* No need to mess up peers contents with
          * arbitrarily long integers - it suffices to
          * know that lastalive is more than 10000s old
          */
         if (lastalive >= 10000) lastalive = 9999;
       }
       lnet_net_unlock(cpt);
       s += snprintf(s, tmpstr + tmpsiz - s, "%-24s %4d %5s %5d %5d %5d %5d %5d %5d %d\n", libcfs_nid2str(nid), nrefs, aliveness, lastalive, maxcr, rtrcr, minrtrcr, txcr, mintxcr, txqnob);
       LASSERT(tmpstr + tmpsiz - s > 0);
     } else { /* peer is NULL */
       lnet_net_unlock(cpt);
     }
     if (hash == LNET_PEER_HASH_SIZE) {
       cpt++;
       hash = 0;
       hoff = 1;
       if (!peer && cpt < LNET_CPT_NUMBER) goto again;
     }
   }
   len = s - tmpstr;  /* how many bytes was written */
   if (len > *lenp) { /* linux-supplied buffer is too small */
     rc = -EINVAL;
   } else if (len > 0) { /* wrote something */
     if (copy_to_user(buffer, tmpstr, len))
       rc = -EFAULT;
     else
       *ppos = LNET_PROC_POS_MAKE(cpt, ver, hash, hoff);
   }
-  LIBCFS_FREE(tmpstr, tmpsiz);
+  kfree(tmpstr);
   if (!rc) *lenp = len;
   return rc;
 }<sep>@@
expression buf,data;
@@
-	LIBCFS_ALLOC(buf, data);
+	buf = kmalloc(data, GFP_NOFS);

@@
expression buf,data;
@@
-		LIBCFS_FREE(buf, data);
+		kfree(buf);