Skip to contentSkip to conversation

cifsd: use kfree to free memory allocated by kzalloc

PATCH In review Muhammad Usama Anjum 6 participants 9 messages Apr 1, 2021 – Apr 7, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifsd: use kfree to free memory allocated by kzalloc

kfree should be used to free memory allocated by kzalloc to avoid any overhead and for maintaining consistency.

Fixes 5dfeb6d945 ("cifsd: use kmalloc() for small allocations")

---
This one place was left in earlier patch. I've already received responsse on that patch. I'm sending a separate patch.

 fs/cifsd/transport_tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifsd/transport_tcp.c +1 -1
index 67163efcf472..040881893417 100644
@@ -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);
 	}
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 17 lines · Muhammad Usama Anjum

kfree should be used to free memory allocated by kzalloc to avoid any overhead and for maintaining consistency.

Fixes 5dfeb6d945 ("cifsd: use kmalloc() for small allocations")

---
This one place was left in earlier patch. I've already received responsse on that patch. I'm sending a separate patch.

 fs/cifsd/transport_tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifsd/transport_tcp.c +0 -0
index 67163efcf472..040881893417 100644

fs/cifsd/transport_tcp.c void ksmbd_tcp_destroy(void) · line 554

Quoted 5 lines
fs/cifsd/transport_tcp.c +1 -1
@@ -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);

We should just delete the ksmbd_free() function completely.

I think that cifsd is being re-written though so it might not be worth it.

regards,
dan carpenter

maintainer
#2 lore raw

2021-04-01 20:50 GMT+09:00, Dan Carpenter <[email protected]>:

Quoted 13 lines · Muhammad Usama Anjum
Quoted 12 lines

kfree should be used to free memory allocated by kzalloc to avoid any overhead and for maintaining consistency.

Fixes 5dfeb6d945 ("cifsd: use kmalloc() for small allocations")

---
This one place was left in earlier patch. I've already received responsse on that patch. I'm sending a separate patch.

 fs/cifsd/transport_tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/cifsd/transport_tcp.c void ksmbd_tcp_destroy(void) · line 554

Quoted 10 lines
fs/cifsd/transport_tcp.c +1 -1
index 67163efcf472..040881893417 100644
@@ -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);

We should just delete the ksmbd_free() function completely.

Yes, I have added your review comment about this to my todo-list. I will do that.

Quoted 3 lines

I think that cifsd is being re-written though so it might not be worth it.

Right.
Thanks!

Quoted 10 lines

regards,
dan carpenter

_______________________________________________
Linux-cifsd-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-cifsd-devel

#3 lore raw

Am 4/1/21 um 2:43 PM schrieb Namjae Jeon:

Quoted 26 lines

2021-04-01 20:50 GMT+09:00, Dan Carpenter <[email protected]>:

Quoted 13 lines · Muhammad Usama Anjum
Quoted 12 lines

kfree should be used to free memory allocated by kzalloc to avoid any overhead and for maintaining consistency.

Fixes 5dfeb6d945 ("cifsd: use kmalloc() for small allocations")

---
This one place was left in earlier patch. I've already received responsse on that patch. I'm sending a separate patch.

  fs/cifsd/transport_tcp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/cifsd/transport_tcp.c void ksmbd_tcp_destroy(void) · line 554

Quoted 10 lines
fs/cifsd/transport_tcp.c +1 -1
index 67163efcf472..040881893417 100644
@@ -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);

We should just delete the ksmbd_free() function completely.

Quoted 6 lines

Yes, I have added your review comment about this to my todo-list. I will do that.

Quoted 3 lines

I think that cifsd is being re-written though so it might not be worth it.

Right.

fwiw, while at it what about renaming everything that still references "cifs" to "smb" ? This is not the 90's... :)

Cheers!
-slow

maintainer
#4 lore raw

2021-04-01 21:50 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 30 lines

Am 4/1/21 um 2:43 PM schrieb Namjae Jeon:

Quoted 29 lines

2021-04-01 20:50 GMT+09:00, Dan Carpenter <[email protected]>:

Quoted 13 lines · Muhammad Usama Anjum
Quoted 12 lines

kfree should be used to free memory allocated by kzalloc to avoid any overhead and for maintaining consistency.

Fixes 5dfeb6d945 ("cifsd: use kmalloc() for small allocations")

---
This one place was left in earlier patch. I've already received responsse on that patch. I'm sending a separate patch.

  fs/cifsd/transport_tcp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/cifsd/transport_tcp.c void ksmbd_tcp_destroy(void) · line 554

Quoted 10 lines
fs/cifsd/transport_tcp.c +1 -1
index 67163efcf472..040881893417 100644
@@ -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);

We should just delete the ksmbd_free() function completely.

Yes, I have added your review comment about this to my todo-list. I will do that.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

I think that cifsd is being re-written though so it might not be worth it.

Right.

fwiw, while at it what about renaming everything that still references "cifs" to "smb" ? This is not the 90's... :)

It is also used with the name "ksmbd". So function and variable prefix are used with ksmbd.

Thanks!

Quoted 5 lines

Cheers!
-slow

#5 lore raw

Am 4/1/21 um 2:59 PM schrieb Namjae Jeon:

Quoted 5 lines

2021-04-01 21:50 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 2 lines

fwiw, while at it what about renaming everything that still references "cifs" to "smb" ? This is not the 90's... :)

It is also used with the name "ksmbd". So function and variable prefix are used with ksmbd.

well, I was thinking of this:

Quoted 1 line

+++ b/fs/cifsd/...

We should really stop using the name cifs for modern implementation of SMB{23} and the code should not be added as fs/cifsd/ to the kernel.

Cheers!
-slow

Signature · 3 lines
Ralph Boehme, Samba Team                https://samba.org/
Samba Developer, SerNet GmbH   https://sernet.de/en/samba/
GPG-Fingerprint   FAE2C6088A24252051C559E4AA1E9B7126399E46
maintainer
#6 lore raw

2021-04-01 22:14 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 7 lines

Am 4/1/21 um 2:59 PM schrieb Namjae Jeon:

Quoted 5 lines

2021-04-01 21:50 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 2 lines

fwiw, while at it what about renaming everything that still references "cifs" to "smb" ? This is not the 90's... :)

It is also used with the name "ksmbd". So function and variable prefix are used with ksmbd.

Quoted 6 lines

well, I was thinking of this:

Quoted 1 line

+++ b/fs/cifsd/...

We should really stop using the name cifs for modern implementation of SMB{23} and the code should not be added as fs/cifsd/ to the kernel.

As I know, currently "cifs" is being used for the subdirectory name for historical reasons and to avoid confusions, even though the CIFS (SMB1) dialect is no longer recommended.

Quoted 10 lines

Cheers!
-slow

--
Ralph Boehme, Samba Team https://samba.org/
Samba Developer, SerNet GmbH https://sernet.de/en/samba/
GPG-Fingerprint FAE2C6088A24252051C559E4AA1E9B7126399E46

reviewer
#7 lore raw
Quoted 10 lines · Namjae Jeon

2021-04-01 22:14 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 9 lines

Am 4/1/21 um 2:59 PM schrieb Namjae Jeon:

Quoted 5 lines

2021-04-01 21:50 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 2 lines

fwiw, while at it what about renaming everything that still references "cifs" to "smb" ? This is not the 90's... :)

It is also used with the name "ksmbd". So function and variable prefix are used with ksmbd.

well, I was thinking of this:

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+++ b/fs/cifsd/...

We should really stop using the name cifs for modern implementation of SMB{23} and the code should not be added as fs/cifsd/ to the kernel.

As I know, currently "cifs" is being used for the subdirectory name for historical reasons and to avoid confusions, even though the CIFS (SMB1) dialect is no longer recommended.

I'm with Ralph. CIFS is history that we need to relegate to the past.

I also agree that wrappers around core memory allocators are to be avoided.

Tom.

#8 lore raw
Quoted 14 lines · Tom Talpey
Quoted 12 lines · Namjae Jeon

2021-04-01 22:14 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 11 lines

Am 4/1/21 um 2:59 PM schrieb Namjae Jeon:

Quoted 5 lines

2021-04-01 21:50 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 2 lines

fwiw, while at it what about renaming everything that still references "cifs" to "smb" ? This is not the 90's... :)

It is also used with the name "ksmbd". So function and variable prefix are used with ksmbd.

well, I was thinking of this:

Quoted 1 line

+++ b/fs/cifsd/...

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

We should really stop using the name cifs for modern implementation of SMB{23} and the code should not be added as fs/cifsd/ to the kernel.

As I know, currently "cifs" is being used for the subdirectory name for historical reasons and to avoid confusions, even though the CIFS (SMB1) dialect is no longer recommended.

I'm with Ralph. CIFS is history that we need to relegate to the past.

Tom, and Ralph.
Some background on the cifsd directory name:

We discussed in length but we decided with cifsd to align with the current directory name cifs for the client.
Just to align with current praxis defined by other filesystems, i.e. nfs. which has nfs for client, nfsd for server
and nfs_common for shared cod and definitions.

Once cifsd lands in the kernel I expect we will start building cifs_common for this purpose.

An alternative would have been to rename the current fs/cifs tree to fs/ksmb but renaming an entire directory tree
felt it might get pushback.
In the end we thought that the module name, that is user visible and there it is important we call it smb3 something
but the source tree is not end-user visible so it was less important what the name was.

(the alternative ending up with fs/cifs fs/ksmbd and fs/cifs_common
would have been terrible)

regards
ronnie sahlberg

Quoted 5 lines

I also agree that wrappers around core memory allocators are to be avoided.

Tom.