From: Muhammad Usama Anjum <musamaanjum@gmail.com>
To: Namjae Jeon <namjae.jeon@samsung.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steve French <sfrench@samba.org>,
Hyunchul Lee <hyc.lee@gmail.com>,
"open list:COMMON INTERNET FILE SYSTEM SERVER (CIFSD)"
<linux-cifs@vger.kernel.org>,
"open list:COMMON INTERNET FILE SYSTEM SERVER (CIFSD)"
<linux-cifsd-devel@lists.sourceforge.net>,
open list <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org, colin.king@canonical.com,
dan.carpenter@oracle.com
Cc: musamaanjum@gmail.com
Subject: [PATCH] cifsd: use kfree to free memory allocated by kmalloc or kzalloc
Date: Thu, 1 Apr 2021 14:08:50 +0500 [thread overview]
Message-ID: <20210401090850.GA2779473@LEGION> (raw)
kfree should be used to free memory allocated by kmalloc or kzalloc to
avoid any overhead and for maintaining consistency.
Fixes: 5dfeb6d945 ("cifsd: use kmalloc() for small allocations")
Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
---
fs/cifsd/buffer_pool.c | 4 ++--
fs/cifsd/mgmt/share_config.c | 2 +-
fs/cifsd/mgmt/user_config.c | 8 ++++----
fs/cifsd/mgmt/user_session.c | 6 +++---
fs/cifsd/smb2pdu.c | 4 ++--
fs/cifsd/vfs_cache.c | 2 +-
6 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/fs/cifsd/buffer_pool.c b/fs/cifsd/buffer_pool.c
index ad2a2c885a2c..a9ef3e703232 100644
--- a/fs/cifsd/buffer_pool.c
+++ b/fs/cifsd/buffer_pool.c
@@ -78,7 +78,7 @@ static int register_wm_size_class(size_t sz)
list_for_each_entry(l, &wm_lists, list) {
if (l->sz == sz) {
write_unlock(&wm_lists_lock);
- kvfree(nl);
+ kfree(nl);
return 0;
}
}
@@ -181,7 +181,7 @@ static void wm_list_free(struct wm_list *l)
list_del(&wm->list);
kvfree(wm);
}
- kvfree(l);
+ kfree(l);
}
static void wm_lists_destroy(void)
diff --git a/fs/cifsd/mgmt/share_config.c b/fs/cifsd/mgmt/share_config.c
index db780febd692..e3d459c4dbb2 100644
--- a/fs/cifsd/mgmt/share_config.c
+++ b/fs/cifsd/mgmt/share_config.c
@@ -102,7 +102,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,
p->pattern = kstrdup(veto_list, GFP_KERNEL);
if (!p->pattern) {
- ksmbd_free(p);
+ kfree(p);
return -ENOMEM;
}
diff --git a/fs/cifsd/mgmt/user_config.c b/fs/cifsd/mgmt/user_config.c
index f0c2f8994a6b..c31e2c4d2d6f 100644
--- a/fs/cifsd/mgmt/user_config.c
+++ b/fs/cifsd/mgmt/user_config.c
@@ -46,8 +46,8 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp)
if (!user->name || !user->passkey) {
kfree(user->name);
- ksmbd_free(user->passkey);
- ksmbd_free(user);
+ kfree(user->passkey);
+ kfree(user);
user = NULL;
}
return user;
@@ -57,8 +57,8 @@ void ksmbd_free_user(struct ksmbd_user *user)
{
ksmbd_ipc_logout_request(user->name);
kfree(user->name);
- ksmbd_free(user->passkey);
- ksmbd_free(user);
+ kfree(user->passkey);
+ kfree(user);
}
int ksmbd_anonymous_user(struct ksmbd_user *user)
diff --git a/fs/cifsd/mgmt/user_session.c b/fs/cifsd/mgmt/user_session.c
index 5a2113bf18ef..fa2140d4755a 100644
--- a/fs/cifsd/mgmt/user_session.c
+++ b/fs/cifsd/mgmt/user_session.c
@@ -53,7 +53,7 @@ static void __session_rpc_close(struct ksmbd_session *sess,
ksmbd_free(resp);
ksmbd_rpc_id_free(entry->id);
- ksmbd_free(entry);
+ kfree(entry);
}
static void ksmbd_session_rpc_clear_list(struct ksmbd_session *sess)
@@ -119,7 +119,7 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
return entry->id;
error:
list_del(&entry->list);
- ksmbd_free(entry);
+ kfree(entry);
return -EINVAL;
}
@@ -174,7 +174,7 @@ void ksmbd_session_destroy(struct ksmbd_session *sess)
ksmbd_release_id(session_ida, sess->id);
ksmbd_ida_free(sess->tree_conn_ida);
- ksmbd_free(sess);
+ kfree(sess);
}
static struct ksmbd_session *__session_lookup(unsigned long long id)
diff --git a/fs/cifsd/smb2pdu.c b/fs/cifsd/smb2pdu.c
index 139041768f65..a4bcf6a85f02 100644
--- a/fs/cifsd/smb2pdu.c
+++ b/fs/cifsd/smb2pdu.c
@@ -1611,7 +1611,7 @@ int smb2_sess_setup(struct ksmbd_work *work)
ksmbd_conn_set_good(work);
sess->state = SMB2_SESSION_VALID;
- ksmbd_free(sess->Preauth_HashValue);
+ kfree(sess->Preauth_HashValue);
sess->Preauth_HashValue = NULL;
} else if (conn->preferred_auth_mech == KSMBD_AUTH_NTLMSSP) {
rc = generate_preauth_hash(work);
@@ -1637,7 +1637,7 @@ int smb2_sess_setup(struct ksmbd_work *work)
ksmbd_conn_set_good(work);
sess->state = SMB2_SESSION_VALID;
- ksmbd_free(sess->Preauth_HashValue);
+ kfree(sess->Preauth_HashValue);
sess->Preauth_HashValue = NULL;
}
} else {
diff --git a/fs/cifsd/vfs_cache.c b/fs/cifsd/vfs_cache.c
index ec631dc6f1fb..f2a863542dc7 100644
--- a/fs/cifsd/vfs_cache.c
+++ b/fs/cifsd/vfs_cache.c
@@ -829,6 +829,6 @@ void ksmbd_destroy_file_table(struct ksmbd_file_table *ft)
__close_file_table_ids(ft, NULL, session_fd_check);
idr_destroy(ft->idr);
- ksmbd_free(ft->idr);
+ kfree(ft->idr);
ft->idr = NULL;
}
--
2.25.1
next reply other threads:[~2021-04-01 9:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20210401090901epcas1p49be3384fda4e000a6e9f40af63833f3a@epcas1p4.samsung.com>
2021-04-01 9:08 ` Muhammad Usama Anjum [this message]
2021-04-01 9:18 ` [PATCH] cifsd: use kfree to free memory allocated by kmalloc or kzalloc Namjae Jeon
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=20210401090850.GA2779473@LEGION \
--to=musamaanjum@gmail.com \
--cc=colin.king@canonical.com \
--cc=dan.carpenter@oracle.com \
--cc=hyc.lee@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-cifsd-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=namjae.jeon@samsung.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=sfrench@samba.org \
/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