cifsd: use kfree to free memory allocated by kmalloc or kzalloc
authorMuhammad Usama Anjum <musamaanjum@gmail.com>
Fri, 2 Apr 2021 00:25:35 +0000 (09:25 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 11 May 2021 00:15:36 +0000 (19:15 -0500)
kfree should be used to free memory allocated by kmalloc or kzalloc to
avoid any overhead and for maintaining consistency.

Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifsd/buffer_pool.c
fs/cifsd/mgmt/share_config.c
fs/cifsd/mgmt/user_config.c
fs/cifsd/mgmt/user_session.c
fs/cifsd/smb2pdu.c
fs/cifsd/transport_tcp.c
fs/cifsd/vfs_cache.c

index ad2a2c8..a9ef3e7 100644 (file)
@@ -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)
index b2bd789..11abdbc 100644 (file)
@@ -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;
                }
 
index f0c2f89..c31e2c4 100644 (file)
@@ -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)
index f5cc7a6..9dfe222 100644 (file)
@@ -55,7 +55,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)
@@ -121,7 +121,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;
 }
 
@@ -176,7 +176,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)
index 0b71994..7549b35 100644 (file)
@@ -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 {
index 67163ef..0408818 100644 (file)
@@ -551,7 +551,7 @@ void ksmbd_tcp_destroy(void)
        list_for_each_entry_safe(iface, tmp, &iface_list, entry) {
                list_del(&iface->entry);
                kfree(iface->name);
-               ksmbd_free(iface);
+               kfree(iface);
        }
 }
 
index ec631dc..f2a8635 100644 (file)
@@ -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;
 }