Mercurial > hvf > hvf-old
changeset 515:211e4a7e930c
cp/fs: don't add files to the fs files list twice
This commit fixes a corruption that lead to an infinite loop while iterating
over fs->files.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 25 Apr 2011 14:43:28 -0400 |
parents | ccc9c9514e3e |
children | bef9aeea6b0b |
files | cp/fs/edf.c |
diffstat | 1 files changed, 5 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/cp/fs/edf.c Mon Apr 25 14:26:41 2011 -0400 +++ b/cp/fs/edf.c Mon Apr 25 14:43:28 2011 -0400 @@ -171,28 +171,22 @@ for(blk=0; blk<fs->dir->FST.ADBC; blk++) { fst = bcache_read(fs->dir, 0, blk); - if (IS_ERR(fst)) + if (IS_ERR(fst)) { + ret = PTR_ERR(fst); goto out_free; + } for(i=0; i<fs->ADT.NFST; i++) { if ((!memcmp(fst[i].FNAME, __fn, 8)) && (!memcmp(fst[i].FTYPE, __ft, 8))) { memcpy(&file->FST, &fst[i], sizeof(struct FST)); - goto found; + mutex_unlock(&fs->lock); + return file; } } } ret = -ENOENT; - goto out_free; - -found: - mutex_init(&file->lock, &edf_file); - list_add_tail(&file->files, &fs->files); - - mutex_unlock(&fs->lock); - - return file; out_free: __free_file(file);