Skip to content

Commit 1e2db01

Browse files
HBh25Ygregkh
authored andcommitted
9p/net: fix possible memory leak in p9_check_errors()
commit ce07087 upstream. When p9pdu_readf() is called with "s?d" attribute, it allocates a pointer that will store a string. But when p9pdu_readf() fails while handling "d" then this pointer will not be freed in p9_check_errors(). Fixes: 51a87c5 ("9p: rework client code to use new protocol support functions") Reviewed-by: Christian Schoenebeck <[email protected]> Signed-off-by: Hangyu Hua <[email protected]> Message-ID: <[email protected]> Signed-off-by: Dominique Martinet <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218235 Signed-off-by: Alexey Panov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c4a2222 commit 1e2db01

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/9p/client.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,14 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
520520
return 0;
521521

522522
if (!p9_is_proto_dotl(c)) {
523-
char *ename;
523+
char *ename = NULL;
524+
524525
err = p9pdu_readf(&req->rc, c->proto_version, "s?d",
525526
&ename, &ecode);
526-
if (err)
527+
if (err) {
528+
kfree(ename);
527529
goto out_err;
530+
}
528531

529532
if (p9_is_proto_dotu(c) && ecode < 512)
530533
err = -ecode;

0 commit comments

Comments
 (0)