aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv/hv_balloon.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hv/hv_balloon.c')
-rw-r--r--drivers/hv/hv_balloon.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index c1ad16f763ce..ce6f984535ec 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -402,7 +402,7 @@ struct dm_info_header {
402 */ 402 */
403 403
404struct dm_info_msg { 404struct dm_info_msg {
405 struct dm_info_header header; 405 struct dm_header hdr;
406 __u32 reserved; 406 __u32 reserved;
407 __u32 info_size; 407 __u32 info_size;
408 __u8 info[]; 408 __u8 info[];
@@ -502,13 +502,17 @@ static void hot_add_req(struct hv_dynmem_device *dm, struct dm_hot_add *msg)
502 502
503static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg) 503static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)
504{ 504{
505 switch (msg->header.type) { 505 struct dm_info_header *info_hdr;
506
507 info_hdr = (struct dm_info_header *)msg->info;
508
509 switch (info_hdr->type) {
506 case INFO_TYPE_MAX_PAGE_CNT: 510 case INFO_TYPE_MAX_PAGE_CNT:
507 pr_info("Received INFO_TYPE_MAX_PAGE_CNT\n"); 511 pr_info("Received INFO_TYPE_MAX_PAGE_CNT\n");
508 pr_info("Data Size is %d\n", msg->header.data_size); 512 pr_info("Data Size is %d\n", info_hdr->data_size);
509 break; 513 break;
510 default: 514 default:
511 pr_info("Received Unknown type: %d\n", msg->header.type); 515 pr_info("Received Unknown type: %d\n", info_hdr->type);
512 } 516 }
513} 517}
514 518
@@ -878,7 +882,7 @@ static int balloon_probe(struct hv_device *dev,
878 balloon_onchannelcallback, dev); 882 balloon_onchannelcallback, dev);
879 883
880 if (ret) 884 if (ret)
881 return ret; 885 goto probe_error0;
882 886
883 dm_device.dev = dev; 887 dm_device.dev = dev;
884 dm_device.state = DM_INITIALIZING; 888 dm_device.state = DM_INITIALIZING;
@@ -890,7 +894,7 @@ static int balloon_probe(struct hv_device *dev,
890 kthread_run(dm_thread_func, &dm_device, "hv_balloon"); 894 kthread_run(dm_thread_func, &dm_device, "hv_balloon");
891 if (IS_ERR(dm_device.thread)) { 895 if (IS_ERR(dm_device.thread)) {
892 ret = PTR_ERR(dm_device.thread); 896 ret = PTR_ERR(dm_device.thread);
893 goto probe_error0; 897 goto probe_error1;
894 } 898 }
895 899
896 hv_set_drvdata(dev, &dm_device); 900 hv_set_drvdata(dev, &dm_device);
@@ -913,12 +917,12 @@ static int balloon_probe(struct hv_device *dev,
913 VM_PKT_DATA_INBAND, 917 VM_PKT_DATA_INBAND,
914 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 918 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
915 if (ret) 919 if (ret)
916 goto probe_error1; 920 goto probe_error2;
917 921
918 t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ); 922 t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);
919 if (t == 0) { 923 if (t == 0) {
920 ret = -ETIMEDOUT; 924 ret = -ETIMEDOUT;
921 goto probe_error1; 925 goto probe_error2;
922 } 926 }
923 927
924 /* 928 /*
@@ -927,7 +931,7 @@ static int balloon_probe(struct hv_device *dev,
927 */ 931 */
928 if (dm_device.state == DM_INIT_ERROR) { 932 if (dm_device.state == DM_INIT_ERROR) {
929 ret = -ETIMEDOUT; 933 ret = -ETIMEDOUT;
930 goto probe_error1; 934 goto probe_error2;
931 } 935 }
932 /* 936 /*
933 * Now submit our capabilities to the host. 937 * Now submit our capabilities to the host.
@@ -960,12 +964,12 @@ static int balloon_probe(struct hv_device *dev,
960 VM_PKT_DATA_INBAND, 964 VM_PKT_DATA_INBAND,
961 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); 965 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
962 if (ret) 966 if (ret)
963 goto probe_error1; 967 goto probe_error2;
964 968
965 t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ); 969 t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);
966 if (t == 0) { 970 if (t == 0) {
967 ret = -ETIMEDOUT; 971 ret = -ETIMEDOUT;
968 goto probe_error1; 972 goto probe_error2;
969 } 973 }
970 974
971 /* 975 /*
@@ -974,18 +978,20 @@ static int balloon_probe(struct hv_device *dev,
974 */ 978 */
975 if (dm_device.state == DM_INIT_ERROR) { 979 if (dm_device.state == DM_INIT_ERROR) {
976 ret = -ETIMEDOUT; 980 ret = -ETIMEDOUT;
977 goto probe_error1; 981 goto probe_error2;
978 } 982 }
979 983
980 dm_device.state = DM_INITIALIZED; 984 dm_device.state = DM_INITIALIZED;
981 985
982 return 0; 986 return 0;
983 987
984probe_error1: 988probe_error2:
985 kthread_stop(dm_device.thread); 989 kthread_stop(dm_device.thread);
986 990
987probe_error0: 991probe_error1:
988 vmbus_close(dev->channel); 992 vmbus_close(dev->channel);
993probe_error0:
994 kfree(send_buffer);
989 return ret; 995 return ret;
990} 996}
991 997
@@ -998,6 +1004,7 @@ static int balloon_remove(struct hv_device *dev)
998 1004
999 vmbus_close(dev->channel); 1005 vmbus_close(dev->channel);
1000 kthread_stop(dm->thread); 1006 kthread_stop(dm->thread);
1007 kfree(send_buffer);
1001 1008
1002 return 0; 1009 return 0;
1003} 1010}