diff options
author | Michael Kelley <mikelley@microsoft.com> | 2018-08-01 23:08:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-08-02 04:20:59 -0400 |
commit | 572086325ce9a9e348b8748e830653f3959e88b6 (patch) | |
tree | 9ddba84c9cd5aec69f778524eff83f5d64399af9 | |
parent | 6ba34171bcbd10321c6cf554e0c1144d170f9d1a (diff) |
Drivers: hv: vmbus: Cleanup synic memory free path
clk_evt memory is not being freed when the synic is shutdown
or when there is an allocation error. Add the appropriate
kfree() call, along with a comment to clarify how the memory
gets freed after an allocation error. Make the free path
consistent by removing checks for NULL since kfree() and
free_page() already do the check.
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hv/hv.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 312fe5ed7c40..748a1c4172a6 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c | |||
@@ -242,6 +242,10 @@ int hv_synic_alloc(void) | |||
242 | 242 | ||
243 | return 0; | 243 | return 0; |
244 | err: | 244 | err: |
245 | /* | ||
246 | * Any memory allocations that succeeded will be freed when | ||
247 | * the caller cleans up by calling hv_synic_free() | ||
248 | */ | ||
245 | return -ENOMEM; | 249 | return -ENOMEM; |
246 | } | 250 | } |
247 | 251 | ||
@@ -254,12 +258,10 @@ void hv_synic_free(void) | |||
254 | struct hv_per_cpu_context *hv_cpu | 258 | struct hv_per_cpu_context *hv_cpu |
255 | = per_cpu_ptr(hv_context.cpu_context, cpu); | 259 | = per_cpu_ptr(hv_context.cpu_context, cpu); |
256 | 260 | ||
257 | if (hv_cpu->synic_event_page) | 261 | kfree(hv_cpu->clk_evt); |
258 | free_page((unsigned long)hv_cpu->synic_event_page); | 262 | free_page((unsigned long)hv_cpu->synic_event_page); |
259 | if (hv_cpu->synic_message_page) | 263 | free_page((unsigned long)hv_cpu->synic_message_page); |
260 | free_page((unsigned long)hv_cpu->synic_message_page); | 264 | free_page((unsigned long)hv_cpu->post_msg_page); |
261 | if (hv_cpu->post_msg_page) | ||
262 | free_page((unsigned long)hv_cpu->post_msg_page); | ||
263 | } | 265 | } |
264 | 266 | ||
265 | kfree(hv_context.hv_numa_map); | 267 | kfree(hv_context.hv_numa_map); |