Skip to content

Commit ffec1cc

Browse files
kelleymhmerwick
authored andcommitted
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 <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: K. Y. Srinivasan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 5720863) Orabug: 28671425 Signed-off-by: Liam Merwick <[email protected]> Reviewed-by: Darren Kenny <[email protected]> Reviewed-by: Alejandro Jimenez <[email protected]> Tested-by: Vijay Balakrishna <[email protected]>
1 parent bed23bb commit ffec1cc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/hv/hv.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ int hv_synic_alloc(void)
242242

243243
return 0;
244244
err:
245+
/*
246+
* Any memory allocations that succeeded will be freed when
247+
* the caller cleans up by calling hv_synic_free()
248+
*/
245249
return -ENOMEM;
246250
}
247251

@@ -254,12 +258,10 @@ void hv_synic_free(void)
254258
struct hv_per_cpu_context *hv_cpu
255259
= per_cpu_ptr(hv_context.cpu_context, cpu);
256260

257-
if (hv_cpu->synic_event_page)
258-
free_page((unsigned long)hv_cpu->synic_event_page);
259-
if (hv_cpu->synic_message_page)
260-
free_page((unsigned long)hv_cpu->synic_message_page);
261-
if (hv_cpu->post_msg_page)
262-
free_page((unsigned long)hv_cpu->post_msg_page);
261+
kfree(hv_cpu->clk_evt);
262+
free_page((unsigned long)hv_cpu->synic_event_page);
263+
free_page((unsigned long)hv_cpu->synic_message_page);
264+
free_page((unsigned long)hv_cpu->post_msg_page);
263265
}
264266

265267
kfree(hv_context.hv_numa_map);

0 commit comments

Comments
 (0)