From: Leon Romanovsky <leon@kernel.org>
To: v9fs-developer@lists.sourceforge.net
Cc: linux_oss@crudebyte.com, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com,
Dominique Martinet <asmadeus@codewreck.org>,
syzbot+67d13108d855f451cafc@syzkaller.appspotmail.com,
davem@davemloft.net, edumazet@google.com, ericvh@gmail.com,
kuba@kernel.org, lucho@ionkov.net, netdev@vger.kernel.org
Subject: [PATCH 1/2] Revert "9p: p9_client_create: use p9_client_destroy on failure"
Date: Thu, 29 Sep 2022 12:37:55 +0300 [thread overview]
Message-ID: <024537aa138893c838d9cacc2e24f311c1e83d25.1664442592.git.leonro@nvidia.com> (raw)
In-Reply-To: <cover.1664442592.git.leonro@nvidia.com>
Rely on proper unwind order.
This reverts commit 3ff51294a05529d0baf6d4b2517e561d12efb9f9.
Reported-by: syzbot+67d13108d855f451cafc@syzkaller.appspotmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.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
next prev parent reply other threads:[~2022-09-29 9:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 9:37 [PATCH 0/2] Fix to latest syzkaller bugs in 9p area Leon Romanovsky
2022-09-29 9:37 ` Leon Romanovsky [this message]
2022-10-04 13:10 ` [PATCH 1/2] Revert "9p: p9_client_create: use p9_client_destroy on failure" Dan Carpenter
2022-10-04 21:01 ` Dominique Martinet
2022-10-06 16:19 ` Leon Romanovsky
2022-09-29 9:37 ` [PATCH 2/2] 9p: destroy client in symmetric order Leon Romanovsky
2022-09-29 10:29 ` Dominique Martinet
2022-09-29 10:53 ` Leon Romanovsky
2022-10-04 13:03 ` Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=024537aa138893c838d9cacc2e24f311c1e83d25.1664442592.git.leonro@nvidia.com \
--to=leon@kernel.org \
--cc=asmadeus@codewreck.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ericvh@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=netdev@vger.kernel.org \
--cc=syzbot+67d13108d855f451cafc@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).