Skip to content

Commit ec97e11

Browse files
dcuiliuw
authored andcommitted
Drivers: hv: vmbus: Call hv_synic_free() if hv_synic_alloc() fails
Commit 5720863 ("Drivers: hv: vmbus: Cleanup synic memory free path") says "Any memory allocations that succeeded will be freed when the caller cleans up by calling hv_synic_free()", but if the get_zeroed_page() in hv_synic_alloc() fails, currently hv_synic_free() is not really called in vmbus_bus_init(), consequently there will be a memory leak, e.g. hv_context.hv_numa_map is not freed in the error path. Fix this by updating the goto labels. Cc: [email protected] Signed-off-by: Dexuan Cui <[email protected]> Fixes: 4df4cb9 ("x86/hyperv: Initialize clockevents earlier in CPU onlining") Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent cb6aeeb commit ec97e11

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/hv/vmbus_drv.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ static int vmbus_bus_init(void)
13721372
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online",
13731373
hv_synic_init, hv_synic_cleanup);
13741374
if (ret < 0)
1375-
goto err_cpuhp;
1375+
goto err_alloc;
13761376
hyperv_cpuhp_online = ret;
13771377

13781378
ret = vmbus_connect();
@@ -1392,9 +1392,8 @@ static int vmbus_bus_init(void)
13921392

13931393
err_connect:
13941394
cpuhp_remove_state(hyperv_cpuhp_online);
1395-
err_cpuhp:
1396-
hv_synic_free();
13971395
err_alloc:
1396+
hv_synic_free();
13981397
if (vmbus_irq == -1) {
13991398
hv_remove_vmbus_handler();
14001399
} else {

0 commit comments

Comments
 (0)