Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] cifs: use kfree in error path of cifs_writedata_alloc()
@ 2022-11-10 11:19 Liu Jian
  2022-11-10 20:30 ` Fwd: " Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Liu Jian @ 2022-11-10 11:19 UTC (permalink / raw)
  To: sfrench, pc, lsahlber, sprasad, tom, zhangxiaoxu5, linux-cifs,
	samba-technical
  Cc: liujian56

'pages' is allocated by kcalloc(), which should freed by kfree().

Fixes: 4153d789e299 ("cifs: Fix pages array leak when writedata alloc failed in cifs_writedata_alloc()")
Signed-off-by: Liu Jian <liujian56@huawei.com>
---
 fs/cifs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index cd9698209930..9a250fee673f 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2440,7 +2440,7 @@ cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete)
 	if (pages) {
 		writedata = cifs_writedata_direct_alloc(pages, complete);
 		if (!writedata)
-			kvfree(pages);
+			kfree(pages);
 	}
 
 	return writedata;
-- 
2.17.1


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

* Fwd: [PATCH] cifs: use kfree in error path of cifs_writedata_alloc()
  2022-11-10 11:19 [PATCH] cifs: use kfree in error path of cifs_writedata_alloc() Liu Jian
@ 2022-11-10 20:30 ` Steve French
  2022-11-10 22:13   ` David Howells
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2022-11-10 20:30 UTC (permalink / raw)
  To: David Howells, liujian56, ZhangXiaoxu, CIFS

The kvfree vs. kfree wasn't obvious to me

Is this just a "it's cleaner" patch? or a bug.  I thought kvfree will
call kfree in this case as mentioned in the link below

https://patchwork.kernel.org/project/dri-devel/patch/1447070170-8512-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp/

---------- Forwarded message ---------
From: Liu Jian <liujian56@huawei.com>
Date: Thu, Nov 10, 2022 at 5:14 AM
Subject: [PATCH] cifs: use kfree in error path of cifs_writedata_alloc()
To: <sfrench@samba.org>, <pc@cjr.nz>, <lsahlber@redhat.com>,
<sprasad@microsoft.com>, <tom@talpey.com>, <zhangxiaoxu5@huawei.com>,
<linux-cifs@vger.kernel.org>, <samba-technical@lists.samba.org>
Cc: <liujian56@huawei.com>


'pages' is allocated by kcalloc(), which should freed by kfree().

Fixes: 4153d789e299 ("cifs: Fix pages array leak when writedata alloc
failed in cifs_writedata_alloc()")
Signed-off-by: Liu Jian <liujian56@huawei.com>
---
 fs/cifs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index cd9698209930..9a250fee673f 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2440,7 +2440,7 @@ cifs_writedata_alloc(unsigned int nr_pages,
work_func_t complete)
        if (pages) {
                writedata = cifs_writedata_direct_alloc(pages, complete);
                if (!writedata)
-                       kvfree(pages);
+                       kfree(pages);
        }

        return writedata;
--
2.17.1



-- 
Thanks,

Steve

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

* Re: Fwd: [PATCH] cifs: use kfree in error path of cifs_writedata_alloc()
  2022-11-10 20:30 ` Fwd: " Steve French
@ 2022-11-10 22:13   ` David Howells
  0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2022-11-10 22:13 UTC (permalink / raw)
  To: Steve French; +Cc: dhowells, liujian56, ZhangXiaoxu, CIFS

Steve French <smfrench@gmail.com> wrote:

> 'pages' is allocated by kcalloc(), which should freed by kfree().

Either kfree() or kvfree() will do; though kfree() is going to be slightly
faster.

David


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

end of thread, other threads:[~2022-11-10 22:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-10 11:19 [PATCH] cifs: use kfree in error path of cifs_writedata_alloc() Liu Jian
2022-11-10 20:30 ` Fwd: " Steve French
2022-11-10 22:13   ` David Howells

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