Skip to content

Commit 79efeba

Browse files
heatdmartinetd
authored andcommitted
9p: Avoid creating multiple slab caches with the same name
In the spirit of [1], avoid creating multiple slab caches with the same name. Instead, add the dev_name into the mix. [1]: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Pedro Falcato <[email protected]> Reported-by: [email protected] Message-ID: <[email protected]> Signed-off-by: Dominique Martinet <[email protected]>
1 parent 1325e4a commit 79efeba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/9p/client.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
979979
int err;
980980
struct p9_client *clnt;
981981
char *client_id;
982+
char *cache_name;
982983

983984
clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
984985
if (!clnt)
@@ -1035,15 +1036,22 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
10351036
if (err)
10361037
goto close_trans;
10371038

1039+
cache_name = kasprintf(GFP_KERNEL, "9p-fcall-cache-%s", dev_name);
1040+
if (!cache_name) {
1041+
err = -ENOMEM;
1042+
goto close_trans;
1043+
}
1044+
10381045
/* P9_HDRSZ + 4 is the smallest packet header we can have that is
10391046
* followed by data accessed from userspace by read
10401047
*/
10411048
clnt->fcall_cache =
1042-
kmem_cache_create_usercopy("9p-fcall-cache", clnt->msize,
1049+
kmem_cache_create_usercopy(cache_name, clnt->msize,
10431050
0, 0, P9_HDRSZ + 4,
10441051
clnt->msize - (P9_HDRSZ + 4),
10451052
NULL);
10461053

1054+
kfree(cache_name);
10471055
return clnt;
10481056

10491057
close_trans:

0 commit comments

Comments
 (0)