2004-09-01 16:50:03

by Dave Jones

[permalink] [raw]
Subject: [PATCH] Fix leaks in ISOFS.

Spotted with the source checker from Coverity.com.

Signed-off-by: Dave Jones <[email protected]>


diff -urpN --exclude-from=/home/davej/.exclude bk-linus/fs/isofs/rock.c linux-2.6/fs/isofs/rock.c
--- bk-linus/fs/isofs/rock.c 2004-07-01 17:44:12.000000000 +0100
+++ linux-2.6/fs/isofs/rock.c 2004-08-23 14:08:20.000000000 +0100
@@ -153,6 +153,7 @@ int get_rock_ridge_filename(struct iso_d
}
}
MAYBE_CONTINUE(repeat,inode);
+ if (buffer) kfree(buffer);
return retnamlen; /* If 0, this file did not have a NM field */
out:
if(buffer) kfree(buffer);
@@ -351,7 +352,6 @@ int parse_rock_ridge_inode_internal(stru
}
}
MAYBE_CONTINUE(repeat,inode);
- return 0;
out:
if(buffer) kfree(buffer);
return 0;
@@ -515,6 +515,8 @@ static int rock_ridge_symlink_readpage(s
}
}
MAYBE_CONTINUE(repeat, inode);
+ if (buffer)
+ kfree(buffer);

if (rpnt == link)
goto fail;


2004-09-01 17:01:39

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] Fix leaks in ISOFS.

> MAYBE_CONTINUE(repeat,inode);
> + if (buffer) kfree(buffer);

kfree(NULL) is just fine

2004-09-01 20:42:51

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] Fix leaks in ISOFS.

On Wed, Sep 01, 2004 at 06:00:50PM +0100, Christoph Hellwig wrote:
> > MAYBE_CONTINUE(repeat,inode);
> > + if (buffer) kfree(buffer);
>
> kfree(NULL) is just fine

True. I got carried away mirroring the style of all the other
kfree operations in that code.

Dave