mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: prevent memory leak on error return
@ 2023-11-08  8:15 Zongmin Zhou
  2023-11-08 10:36 ` Namjae Jeon
  0 siblings, 1 reply; 8+ messages in thread
From: Zongmin Zhou @ 2023-11-08  8:15 UTC (permalink / raw)
  To: linkinjeon, sfrench
  Cc: senozhatsky, tom, linux-cifs, linux-kernel, Zongmin Zhou,
	kernel test robot, Dan Carpenter, Zongmin Zhou

When allocated memory for 'new' failed,just return
will cause memory leak of 'ar'.

Fixes: 1819a9042999 ("ksmbd: reorganize ksmbd_iov_pin_rsp()")

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202311031837.H3yo7JVl-lkp@intel.com/
Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
---
 fs/smb/server/ksmbd_work.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/ksmbd_work.c b/fs/smb/server/ksmbd_work.c
index a2ed441e837a..dbbef686e160 100644
--- a/fs/smb/server/ksmbd_work.c
+++ b/fs/smb/server/ksmbd_work.c
@@ -123,8 +123,10 @@ static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len,
 		new = krealloc(work->iov,
 			       sizeof(struct kvec) * work->iov_alloc_cnt,
 			       GFP_KERNEL | __GFP_ZERO);
-		if (!new)
+		if (!new) {
+			kfree(ar);
 			return -ENOMEM;
+		}
 		work->iov = new;
 	}
 
-- 
2.34.1


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

end of thread, other threads:[~2023-11-20  1:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08  8:15 [PATCH] ksmbd: prevent memory leak on error return Zongmin Zhou
2023-11-08 10:36 ` Namjae Jeon
2023-11-09  1:17   ` [PATCH v2] " Zongmin Zhou
2023-11-09 13:21     ` Namjae Jeon
2023-11-19  9:14     ` Pierre Mariani
2023-11-19 14:17       ` Namjae Jeon
2023-11-20  1:33         ` Zongmin Zhou
2023-11-20  1:38           ` Namjae Jeon

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

all inboxes | Powered by JetHome®