Skip to contentSkip to conversation

net/9p/trans_fd: check the return value of parse_opts

PATCH New Li Zhong 1 participant 1 message Sep 22, 2022

Subsystems (3)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH v2 1/1 net/9p/trans_fd: check the return value of parse_opts

parse_opts() could fail when there is error parsing mount options into p9_fd_opts structure due to allocation failure. In that case opts will contain invalid data. Though the value check on opts will prevent invalid data from being used, we still add the check and return the error code to avoid confusions for developers.

---
 net/9p/trans_fd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/9p/trans_fd.c +3 -1
index e758978b44be..11ae64c1a24b 100644
@@ -1061,7 +1061,9 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
 	int err;
 	struct p9_fd_opts opts;
 
-	parse_opts(args, &opts);
+	err = parse_opts(args, &opts);
+	if (err < 0)
+		return err;
 	client->trans_opts.fd.rfd = opts.rfd;
 	client->trans_opts.fd.wfd = opts.wfd;
 
Signature · 1 line
2.25.1