fat: cleanup fat_parse_long() error handling
authorDarren Jenkins <[email protected]>
Thu, 6 Nov 2008 20:53:48 +0000 (12:53 -0800)
committerLinus Torvalds <[email protected]>
Thu, 6 Nov 2008 23:41:20 +0000 (15:41 -0800)
Coverity CID 2332 & 2333 RESOURCE_LEAK

In fat_search_long() if fat_parse_long() returns a -ve value we return
without first freeing unicode.  This patch free's them on this error path.

The above was false positive on current tree, but this change is more
clean, so apply as cleanup.

[[email protected]: fix coding style]
Signed-off-by: Darren Jenkins <[email protected]>
Signed-off-by: OGAWA Hirofumi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/fat/dir.c

index 931dd28b52899cb4d55a534ed733509e653bde47..140fc39e23076fe139a04827617f4d33fc1299d5 100644 (file)
@@ -373,9 +373,10 @@ parse_record:
                if (de->attr == ATTR_EXT) {
                        int status = fat_parse_long(inode, &cpos, &bh, &de,
                                                    &unicode, &nr_slots);
-                       if (status < 0)
-                               return status;
-                       else if (status == PARSE_INVALID)
+                       if (status < 0) {
+                               err = status;
+                               goto end_of_dir;
+                       } else if (status == PARSE_INVALID)
                                continue;
                        else if (status == PARSE_NOT_LONGNAME)
                                goto parse_record;