fs/fat/dir.c fix resource leak
Subsystems (2)
PATCH 1/1 fs/fat/dir.c fix resource leak
G'day people,
Coverity CID 2332 & 2333 RESOURCE_LEAK
In fat_search_long() if fat_parse_long() returns a -ve value we return without first freeing unicode and bufname.
This patch free's them on this error path.
Patch against linux-next commit 99be8ca04aa13c0ff10bbb3ba5f90676b050fcc6 Only compile tested
Signed-off-by: Darren Jenkins <darrenrjenkins@gmailcom>
fs/fat/dir.c +7 -5
@@ -346,14 +346,16 @@ 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 EODir; + }else if (status =PARSE_INVALID ) {continue ; -else if (status =PARSE_NOT_LONGNAME ) + }else if (status =PARSE_NOT_LONGNAME ) { goto parse_record; -else if (status =PARSE_EOF ) + }else if (status =PARSE_EOF ) { goto EODir; + } }memcpy (work, de->name,sizeof (de->name));
OGAWA Hirofumi
maintainerQuoted 7 lines · Darren Jenkins\
Coverity CID 2332 & 2333
RESOURCE_LEAKIn
fat_search_long()iffat_parse_long()returns a -ve value we return without first freeing unicode and bufname.
This patch free's them on this error path.Signed-off-by Darren Jenkins <darrenrjenkins@gmailcom>
I'll apply to current code. Thanks.
BTW, email address of Signed-off-by line is typo?
Signature · 1 line
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 11 lines · OGAWA Hirofumi
Quoted 7 lines · Darren Jenkins\
Coverity CID 2332 & 2333
RESOURCE_LEAKIn
fat_search_long()iffat_parse_long()returns a -ve value we return without first freeing unicode and bufname.
This patch free's them on this error path.Signed-off-by Darren Jenkins <darrenrjenkins@gmailcom>I'll apply to current code. Thanks.
I noticed this is false positive. bufname is not used anymore, and fat_parse_long() never returns error after allocating unicode.
Instead, I'll apply this as cleanup.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 1 line · OGAWA Hirofumi
BTW, email address of Signed-off-by line is typo?
Yes, my mistake.
Signed-off-by: Darren Jenkins <[email protected]>
Quoted 2 lines
I noticed this is false positive. bufname is not used anymore, and
fat_parse_long()never returns error after allocating unicode.
Yes you are right about unicode, I should of picked that up.
bufname is not used anymore ? I'm not sure what you mean? are you talking about an external tree ?
Darren Jenkins ÿôèº{.nÇ+‰·Ÿ®‰†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¤z¹Ş—øÚ�+h®Ïâ�Ø^n‡r¡ö¦zË�ëh™¨èÚ&£ûàz¿äz¹Ş—ú+€Ê+zf£¢·hšˆ§~††Ûiÿÿï�êÿ‘êçz_è®æj:+v‰¨ş)ߣøm
OGAWA Hirofumi
maintainerQuoted 2 lines · Darren Jenkins
bufname is not used anymore ? I'm not sure what you mean? are you talking about an external tree ?
No, about current Linus tree. I meant, bufname is used actually, but it's not allocated dynamically by __getname().
Thanks.
Signature · 5 lines
OGAWA Hirofumi <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html