Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit bf050cc

Browse files
Zhu Jungregkh
Zhu Jun
authored andcommitted
tools/hv: Add memory allocation check in hv_fcopy_start
[ Upstream commit 94e86b1 ] 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>
1 parent f6d50dd commit bf050cc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/hv/hv_fcopy_uio_daemon.c

+7
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ static int hv_fcopy_start(struct hv_start_fcopy *smsg_in)
296296
file_name = (char *)malloc(file_size * sizeof(char));
297297
path_name = (char *)malloc(path_size * sizeof(char));
298298

299+
if (!file_name || !path_name) {
300+
free(file_name);
301+
free(path_name);
302+
syslog(LOG_ERR, "Can't allocate memory for file name and/or path name");
303+
return HV_E_FAIL;
304+
}
305+
299306
wcstoutf8(file_name, (__u16 *)in_file_name, file_size);
300307
wcstoutf8(path_name, (__u16 *)in_path_name, path_size);
301308

0 commit comments

Comments
 (0)