Skip to content

Commit

Permalink
Merge tag 'char-misc-3.8-rc4' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg Kroah-Hartman:
 "Here are two hyperv patches for 3.8-rc4 that fix some reported
  problems hv_balloon driver"

* tag 'char-misc-3.8-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  Drivers: hv: balloon: Fix a memory leak
  Drivers: hv: balloon: Fix a bug in the definition of struct dm_info_msg
  • Loading branch information
torvalds committed Jan 18, 2013
2 parents 5c69bed + 33080c1 commit 0d060d2
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions drivers/hv/hv_balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ struct dm_info_header {
*/

struct dm_info_msg {
struct dm_info_header header;
struct dm_header hdr;
__u32 reserved;
__u32 info_size;
__u8 info[];
Expand Down Expand Up @@ -503,13 +503,17 @@ static void hot_add_req(struct hv_dynmem_device *dm, struct dm_hot_add *msg)

static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)
{
switch (msg->header.type) {
struct dm_info_header *info_hdr;

info_hdr = (struct dm_info_header *)msg->info;

switch (info_hdr->type) {
case INFO_TYPE_MAX_PAGE_CNT:
pr_info("Received INFO_TYPE_MAX_PAGE_CNT\n");
pr_info("Data Size is %d\n", msg->header.data_size);
pr_info("Data Size is %d\n", info_hdr->data_size);
break;
default:
pr_info("Received Unknown type: %d\n", msg->header.type);
pr_info("Received Unknown type: %d\n", info_hdr->type);
}
}

Expand Down Expand Up @@ -879,7 +883,7 @@ static int balloon_probe(struct hv_device *dev,
balloon_onchannelcallback, dev);

if (ret)
return ret;
goto probe_error0;

dm_device.dev = dev;
dm_device.state = DM_INITIALIZING;
Expand All @@ -891,7 +895,7 @@ static int balloon_probe(struct hv_device *dev,
kthread_run(dm_thread_func, &dm_device, "hv_balloon");
if (IS_ERR(dm_device.thread)) {
ret = PTR_ERR(dm_device.thread);
goto probe_error0;
goto probe_error1;
}

hv_set_drvdata(dev, &dm_device);
Expand All @@ -914,12 +918,12 @@ static int balloon_probe(struct hv_device *dev,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret)
goto probe_error1;
goto probe_error2;

t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);
if (t == 0) {
ret = -ETIMEDOUT;
goto probe_error1;
goto probe_error2;
}

/*
Expand All @@ -928,7 +932,7 @@ static int balloon_probe(struct hv_device *dev,
*/
if (dm_device.state == DM_INIT_ERROR) {
ret = -ETIMEDOUT;
goto probe_error1;
goto probe_error2;
}
/*
* Now submit our capabilities to the host.
Expand Down Expand Up @@ -961,12 +965,12 @@ static int balloon_probe(struct hv_device *dev,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret)
goto probe_error1;
goto probe_error2;

t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);
if (t == 0) {
ret = -ETIMEDOUT;
goto probe_error1;
goto probe_error2;
}

/*
Expand All @@ -975,18 +979,20 @@ static int balloon_probe(struct hv_device *dev,
*/
if (dm_device.state == DM_INIT_ERROR) {
ret = -ETIMEDOUT;
goto probe_error1;
goto probe_error2;
}

dm_device.state = DM_INITIALIZED;

return 0;

probe_error1:
probe_error2:
kthread_stop(dm_device.thread);

probe_error0:
probe_error1:
vmbus_close(dev->channel);
probe_error0:
kfree(send_buffer);
return ret;
}

Expand All @@ -999,6 +1005,7 @@ static int balloon_remove(struct hv_device *dev)

vmbus_close(dev->channel);
kthread_stop(dm->thread);
kfree(send_buffer);

return 0;
}
Expand Down

0 comments on commit 0d060d2

Please sign in to comment.