Drivers: hv: util: two fixes
cover Drivers: hv: util: two fixes
Fix two issues reported by Dan Carpenter and kbuild test robot.
Vitaly Kuznetsov (2):
Drivers: hv: kvp: check kzalloc return value
Drivers: hv: fcopy: dynamically allocate smsg_out in fcopy_send_data()
drivers/hv/hv_fcopy.c | 21 +++++++++++++-------- drivers/hv/hv_kvp.c | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.3
PATCH 1/2 Drivers: hv: kvp: check kzalloc return value
kzalloc() return value check was accidentally lost in 11bc3a5fa91f:
"Drivers: hv: kvp: convert to hv_utils_transport" commit.
We don't need to reset kvp_transaction.state here as we have the kvp_timeout_func() timeout function and in case we're in OOM situation it is preferable to wait.
--- drivers/hv/hv_kvp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hv/hv_kvp.c +3 -0
@@ -353,6 +353,9 @@ kvp_send_key(struct work_struct *dummy)return ; message =kzalloc (sizeof (*message),GFP_KERNEL ); +if (!message) +return ; + message->kvp_hdr.operation = operation; message->kvp_hdr.pool = pool; in_msg = kvp_transaction.kvp_msg;
Signature · 1 line
1.9.3
PATCH 2/2 Drivers: hv: fcopy: dynamically allocate smsg_out in fcopy_send_data()
In reply to Vitaly Kuznetsovstruct hv_start_fcopy is too big to be on stack on i386, the following warning is reported:
Quoted 1 line
Quoted 1 line
drivers/hv/hv_fcopy.c:159:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
--- drivers/hv/hv_fcopy.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/hv/hv_fcopy.c +13 -8
@@ -116,7 +116,7 @@ static int fcopy_handle_handshake(u32 version)static void fcopy_send_data (struct work_struct *dummy) { -struct hv_start_fcopy smsg_out; +struct hv_start_fcopy *smsg_out =NULL ;int operation = fcopy_transaction.fcopy_msg->operation;struct hv_start_fcopy *smsg_in;void *out_src;
@@ -136,21 +136,24 @@ static void fcopy_send_data(struct work_struct *dummy)switch (operation) {case START_FILE_COPY : out_len =sizeof (struct hv_start_fcopy ); -memset (&smsg_out,0 , out_len); - smsg_out.hdr.operation = operation; + smsg_out =kzalloc (sizeof (*smsg_out),GFP_KERNEL ); +if (!smsg_out) +return ; + + smsg_out->hdr.operation = operation; smsg_in = (struct hv_start_fcopy *)fcopy_transaction.fcopy_msg;utf16s_to_utf8s ((wchar_t *)smsg_in->file_name,W_MAX_PATH ,UTF16_LITTLE_ENDIAN , - (__u8 *)&smsg_out.file_name,W_MAX_PATH -1 ); + (__u8 *)&smsg_out->file_name,W_MAX_PATH -1 );utf16s_to_utf8s ((wchar_t *)smsg_in->path_name,W_MAX_PATH ,UTF16_LITTLE_ENDIAN , - (__u8 *)&smsg_out.path_name,W_MAX_PATH -1 ); + (__u8 *)&smsg_out->path_name,W_MAX_PATH -1 ); - smsg_out.copy_flags = smsg_in->copy_flags; - smsg_out.file_size = smsg_in->file_size; - out_src = &smsg_out; + smsg_out->copy_flags = smsg_in->copy_flags; + smsg_out->file_size = smsg_in->file_size; + out_src = smsg_out;break ;default :
@@ -168,6 +171,8 @@ static void fcopy_send_data(struct work_struct *dummy) fcopy_transaction.state =HVUTIL_READY ; } } +kfree (smsg_out); +return ; }
Signature · 1 line
1.9.3