From f3dd00895b2e1301dcd1a9a7ac8fd142ddb4830a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 29 Jun 2022 14:22:28 -0700 Subject: [PATCH] Don't allocate zero size net info Clients don't use the net conn info and specified that it has 0 size. The net layer would try and allocate a zero size region which returns the magic ZERO_SIZE_PTR, which it would then later try and free. While that works, it's a little goofy. We can avoid the allocation when the size is 0. The pointer will remain null which kfree also accepts. Signed-off-by: Zach Brown --- kmod/src/net.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kmod/src/net.c b/kmod/src/net.c index 93478a5f..1ef6db35 100644 --- a/kmod/src/net.c +++ b/kmod/src/net.c @@ -1345,10 +1345,12 @@ scoutfs_net_alloc_conn(struct super_block *sb, if (!conn) return NULL; - conn->info = kzalloc(info_size, GFP_NOFS); - if (!conn->info) { - kfree(conn); - return NULL; + if (info_size) { + conn->info = kzalloc(info_size, GFP_NOFS); + if (!conn->info) { + kfree(conn); + return NULL; + } } conn->workq = alloc_workqueue("scoutfs_net_%s",