kfree in fs/nfsd/nfs4xdr.c:savemem()
Subsystems (2)
PATCH 1/1 kfree in fs/nfsd/nfs4xdr.c:savemem()
The wrong pointer is being kfree'd in savemem() when defer_free returns with an error.
Benny
fs/nfsd/nfs4xdr.c 2006-12-25 09:15:58.000000000 +0200 renamed from fs/nfsd/nfs4xdr.c 2006-12-18 19:18:45.000000000 +0200 +1 -1
@@ -197,23 +197,23 @@ static char *savemem(struct nfsd4_compou if (p == argp->tmp) { new = kmalloc(nbytes, GFP_KERNEL); if (!new) return NULL; p = new; memcpy(p, argp->tmp, nbytes); } else { if (p != argp->tmpp) BUG(); argp->tmpp = NULL; } if (defer_free(argp, kfree, p)) { - kfree(new); + kfree(p); return NULL; } else return (char *)p; } static int nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) { u32 bmlen; DECODE_HEAD;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 2 lines · Benny Halevy
The wrong pointer is being kfree'd in
savemem()whendefer_freereturns with an error.
Makes sense to me, thanks!
That makes "new" unnecessary. Any objection to the following? (untested).
Since this seems to be a rare memory leak, I'm inclined to leave this till after 2.6.20.
--b.
fs/nfsd/nfs4xdr.c +3 -5
@@ -199,18 +199,16 @@ defer_free(struct nfsd4_compoundargs *argp,static char *savemem (struct nfsd4_compoundargs *argp,__be32 *p,int nbytes) { -void *new =NULL ;if (p == argp->tmp) { - new =kmalloc (nbytes,GFP_KERNEL ); -if (!new)return NULL ; - p = new; + p =kmalloc (nbytes,GFP_KERNEL ); +if (!p)return NULL ;memcpy (p, argp->tmp, nbytes); }else {BUG_ON (p != argp->tmpp); argp->tmpp =NULL ; }if (defer_free (argp, kfree, p)) { -kfree (new); +kfree (p);return NULL ; }else return (char *)p;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 9 lines · J. Bruce Fields
Quoted 2 lines · Benny Halevy
The wrong pointer is being kfree'd in
savemem()whendefer_freereturns with an error.Makes sense to me, thanks!
That makes "new" unnecessary. Any objection to the following? (untested).
This seems to be right on the spot...
Quoted 3 lines
Since this seems to be a rare memory leak, I'm inclined to leave this till after 2.6.20.
Agreed.
Quoted 20 lines
--b.
fs/nfsd/nfs4xdr.c +2
-4@@ -199,18 +199,16 @@ defer_free(struct nfsd4_compoundargs *argp,static char *savemem (struct nfsd4_compoundargs *argp,__be32 *p,int nbytes) { -void *new =NULL ;if (p == argp->tmp) { - new =kmalloc (nbytes,GFP_KERNEL ); -if (!new)return NULL ; - p = new; + p =kmalloc (nbytes,GFP_KERNEL ); +if (!p)return NULL ;memcpy (p, argp->tmp, nbytes);
fs/nfsd/nfs4xdr.c defer_free(struct nfsd4_compoundargs *argp, · line 214
Quoted 10 lines
fs/nfsd/nfs4xdr.c +1
-1}else {BUG_ON (p != argp->tmpp); argp->tmpp =NULL ; }if (defer_free (argp, kfree, p)) { -kfree (new); +kfree (p);return NULL ; }else return (char *)p;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs