Skip to content

Commit ce07087

Browse files
HBh25Ymartinetd
authored andcommitted
9p/net: fix possible memory leak in p9_check_errors()
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]>
1 parent e02be63 commit ce07087

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/9p/client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,14 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
540540
return 0;
541541

542542
if (!p9_is_proto_dotl(c)) {
543-
char *ename;
543+
char *ename = NULL;
544544

545545
err = p9pdu_readf(&req->rc, c->proto_version, "s?d",
546546
&ename, &ecode);
547-
if (err)
547+
if (err) {
548+
kfree(ename);
548549
goto out_err;
550+
}
549551

550552
if (p9_is_proto_dotu(c) && ecode < 512)
551553
err = -ecode;

0 commit comments

Comments
 (0)