* [PATCH AUTOSEL 6.10 183/197] tools/hv: Add memory allocation check in hv_fcopy_start
[not found] <20240925115823.1303019-1-sashal@kernel.org>
@ 2024-09-25 11:53 ` Sasha Levin
0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2024-09-25 11:53 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Zhu Jun, Dexuan Cui, Saurabh Sengar, Wei Liu, Sasha Levin, kys,
haiyangz, linux-hyperv
From: Zhu Jun <zhujun2@cmss.chinamobile.com>
[ Upstream commit 94e86b174d103d941b4afc4f016af8af9e5352fa ]
Added error handling for memory allocation failures
of file_name and path_name.
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Tested-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Link: https://lore.kernel.org/r/20240906091333.11419-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <20240906091333.11419-1-zhujun2@cmss.chinamobile.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/hv/hv_fcopy_uio_daemon.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/hv/hv_fcopy_uio_daemon.c b/tools/hv/hv_fcopy_uio_daemon.c
index 3ce316cc9f970..7a00f3066a980 100644
--- a/tools/hv/hv_fcopy_uio_daemon.c
+++ b/tools/hv/hv_fcopy_uio_daemon.c
@@ -296,6 +296,13 @@ static int hv_fcopy_start(struct hv_start_fcopy *smsg_in)
file_name = (char *)malloc(file_size * sizeof(char));
path_name = (char *)malloc(path_size * sizeof(char));
+ if (!file_name || !path_name) {
+ free(file_name);
+ free(path_name);
+ syslog(LOG_ERR, "Can't allocate memory for file name and/or path name");
+ return HV_E_FAIL;
+ }
+
wcstoutf8(file_name, (__u16 *)in_file_name, file_size);
wcstoutf8(path_name, (__u16 *)in_path_name, path_size);
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-25 12:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240925115823.1303019-1-sashal@kernel.org>
2024-09-25 11:53 ` [PATCH AUTOSEL 6.10 183/197] tools/hv: Add memory allocation check in hv_fcopy_start Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).