[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <024537aa138893c838d9cacc2e24f311c1e83d25.1664442592.git.leonro@nvidia.com>
Date: Thu, 29 Sep 2022 12:37:55 +0300
From: Leon Romanovsky <leon@...nel.org>
To: v9fs-developer@...ts.sourceforge.net
Cc: linux_oss@...debyte.com, linux-kernel@...r.kernel.org,
syzkaller-bugs@...glegroups.com,
Dominique Martinet <asmadeus@...ewreck.org>,
syzbot+67d13108d855f451cafc@...kaller.appspotmail.com,
davem@...emloft.net, edumazet@...gle.com, ericvh@...il.com,
kuba@...nel.org, lucho@...kov.net, netdev@...r.kernel.org
Subject: [PATCH 1/2] Revert "9p: p9_client_create: use p9_client_destroy on failure"
Rely on proper unwind order.
This reverts commit 3ff51294a05529d0baf6d4b2517e561d12efb9f9.
Reported-by: syzbot+67d13108d855f451cafc@...kaller.appspotmail.com
Signed-off-by: Leon Romanovsky <leon@...nel.org>
---
net/9p/client.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index bfa80f01992e..aaa37b07e30a 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -961,10 +961,14 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
char *client_id;
err = 0;
- clnt = kzalloc(sizeof(*clnt), GFP_KERNEL);
+ clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
if (!clnt)
return ERR_PTR(-ENOMEM);
+ clnt->trans_mod = NULL;
+ clnt->trans = NULL;
+ clnt->fcall_cache = NULL;
+
client_id = utsname()->nodename;
memcpy(clnt->name, client_id, strlen(client_id) + 1);
@@ -974,7 +978,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
err = parse_opts(options, clnt);
if (err < 0)
- goto out;
+ goto free_client;
if (!clnt->trans_mod)
clnt->trans_mod = v9fs_get_default_trans();
@@ -983,7 +987,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
err = -EPROTONOSUPPORT;
p9_debug(P9_DEBUG_ERROR,
"No transport defined or default transport\n");
- goto out;
+ goto free_client;
}
p9_debug(P9_DEBUG_MUX, "clnt %p trans %p msize %d protocol %d\n",
@@ -991,7 +995,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
err = clnt->trans_mod->create(clnt, dev_name, options);
if (err)
- goto out;
+ goto put_trans;
if (clnt->msize > clnt->trans_mod->maxsize) {
clnt->msize = clnt->trans_mod->maxsize;
@@ -1005,12 +1009,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
p9_debug(P9_DEBUG_ERROR,
"Please specify a msize of at least 4k\n");
err = -EINVAL;
- goto out;
+ goto close_trans;
}
err = p9_client_version(clnt);
if (err)
- goto out;
+ goto close_trans;
/* P9_HDRSZ + 4 is the smallest packet header we can have that is
* followed by data accessed from userspace by read
@@ -1023,8 +1027,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
return clnt;
-out:
- p9_client_destroy(clnt);
+close_trans:
+ clnt->trans_mod->close(clnt);
+put_trans:
+ v9fs_put_trans(clnt->trans_mod);
+free_client:
+ kfree(clnt);
return ERR_PTR(err);
}
EXPORT_SYMBOL(p9_client_create);
--
2.37.3
Powered by blists - more mailing lists