Fwd: [PATCH] cifs: use kfree in error path of cifs_writedata_alloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx/

---------- Forwarded message ---------
From: Liu Jian <liujian56@xxxxxxxxxx>
Date: Thu, Nov 10, 2022 at 5:14 AM
Subject: [PATCH] cifs: use kfree in error path of cifs_writedata_alloc()
To: <sfrench@xxxxxxxxx>, <pc@xxxxxx>, <lsahlber@xxxxxxxxxx>,
<sprasad@xxxxxxxxxxxxx>, <tom@xxxxxxxxxx>, <zhangxiaoxu5@xxxxxxxxxx>,
<linux-cifs@xxxxxxxxxxxxxxx>, <samba-technical@xxxxxxxxxxxxxxx>
Cc: <liujian56@xxxxxxxxxx>


'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@xxxxxxxxxx>
---
 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



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux