public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] smb: client: Better exception handling in smb3_simple_fallocate_range()
@ 2025-10-08 18:44 Markus Elfring
  2025-10-08 18:46 ` [PATCH 1/2] smb: client: Return directly after a failed SMB2_ioctl() " Markus Elfring
  2025-10-08 18:48 ` [PATCH 2/2] smb: client: Improve memory release " Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Elfring @ 2025-10-08 18:44 UTC (permalink / raw)
  To: linux-cifs, samba-technical, Aurelien Aptel, Bharath SM,
	Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Steve French,
	Tom Talpey
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Oct 2025 20:36:40 +0200

Refine a few implementation details for further development considerations.

Markus Elfring (2):
  Return directly after a failed SMB2_ioctl()
  Improve memory release

 fs/smb/client/smb2ops.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] smb: client: Return directly after a failed SMB2_ioctl() in smb3_simple_fallocate_range()
  2025-10-08 18:44 [PATCH 0/2] smb: client: Better exception handling in smb3_simple_fallocate_range() Markus Elfring
@ 2025-10-08 18:46 ` Markus Elfring
  2025-10-08 18:48 ` [PATCH 2/2] smb: client: Improve memory release " Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-10-08 18:46 UTC (permalink / raw)
  To: linux-cifs, samba-technical, Aurelien Aptel, Bharath SM,
	Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Steve French,
	Tom Talpey
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Oct 2025 20:02:00 +0200

* Return directly after a call of the function “SMB2_ioctl” failed
  at the beginning.

* Delete an initialisation for the local variable “out_data”
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/smb/client/smb2ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 7c3e96260fd4..ec188dedbf97 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -3537,7 +3537,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
 				       struct cifsFileInfo *cfile,
 				       loff_t off, loff_t len)
 {
-	struct file_allocated_range_buffer in_data, *out_data = NULL, *tmp_data;
+	struct file_allocated_range_buffer in_data, *out_data, *tmp_data;
 	u32 out_data_len;
 	char *buf = NULL;
 	loff_t l;
@@ -3552,7 +3552,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
 			1024 * sizeof(struct file_allocated_range_buffer),
 			(char **)&out_data, &out_data_len);
 	if (rc)
-		goto out;
+		return rc;
 
 	buf = kzalloc(1024 * 1024, GFP_KERNEL);
 	if (buf == NULL) {
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] smb: client: Improve memory release in smb3_simple_fallocate_range()
  2025-10-08 18:44 [PATCH 0/2] smb: client: Better exception handling in smb3_simple_fallocate_range() Markus Elfring
  2025-10-08 18:46 ` [PATCH 1/2] smb: client: Return directly after a failed SMB2_ioctl() " Markus Elfring
@ 2025-10-08 18:48 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-10-08 18:48 UTC (permalink / raw)
  To: linux-cifs, samba-technical, Aurelien Aptel, Bharath SM,
	Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Steve French,
	Tom Talpey
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Oct 2025 20:21:38 +0200

* Adjust jump targets so that kfree() functions will be called in
  a recommended order at the end of this function implementation.

* Delete an initialisation for the local variable “buf”
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/smb/client/smb2ops.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index ec188dedbf97..38cef1ff3826 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -3557,7 +3557,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
 	buf = kzalloc(1024 * 1024, GFP_KERNEL);
 	if (buf == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto free_data;
 	}
 
 	tmp_data = out_data;
@@ -3568,12 +3568,12 @@ static int smb3_simple_fallocate_range(unsigned int xid,
 		if (out_data_len == 0) {
 			rc = smb3_simple_fallocate_write_range(xid, tcon,
 					       cfile, off, len, buf);
-			goto out;
+			goto free_buf;
 		}
 
 		if (out_data_len < sizeof(struct file_allocated_range_buffer)) {
 			rc = -EINVAL;
-			goto out;
+			goto free_buf;
 		}
 
 		if (off < le64_to_cpu(tmp_data->file_offset)) {
@@ -3588,11 +3588,12 @@ static int smb3_simple_fallocate_range(unsigned int xid,
 			rc = smb3_simple_fallocate_write_range(xid, tcon,
 					       cfile, off, l, buf);
 			if (rc)
-				goto out;
+				goto free_buf;
+
 			off = off + l;
 			len = len - l;
 			if (len == 0)
-				goto out;
+				goto free_buf;
 		}
 		/*
 		 * We are at a section of allocated data, just skip forward
@@ -3608,10 +3609,10 @@ static int smb3_simple_fallocate_range(unsigned int xid,
 		tmp_data = &tmp_data[1];
 		out_data_len -= sizeof(struct file_allocated_range_buffer);
 	}
-
- out:
-	kfree(out_data);
+free_buf:
 	kfree(buf);
+free_data:
+	kfree(out_data);
 	return rc;
 }
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-08 18:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-08 18:44 [PATCH 0/2] smb: client: Better exception handling in smb3_simple_fallocate_range() Markus Elfring
2025-10-08 18:46 ` [PATCH 1/2] smb: client: Return directly after a failed SMB2_ioctl() " Markus Elfring
2025-10-08 18:48 ` [PATCH 2/2] smb: client: Improve memory release " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox