Skip to content

Commit

Permalink
staging: vc-sm-cma: Use devm_ allocs for sm_state.
Browse files Browse the repository at this point in the history
Use managed allocations for sm_state, removing reliance on
manual management.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
  • Loading branch information
6by9 authored and Phil Elwell committed May 28, 2019
1 parent b2e8c1b commit 8652e3e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
Expand Up @@ -656,7 +656,7 @@ static void vc_sm_connected_init(void)
__func__, ret);

ret = -EIO;
goto err_free_mem;
goto err_failed;
}

ret = vchi_connect(vchi_instance);
Expand All @@ -665,7 +665,7 @@ static void vc_sm_connected_init(void)
__func__, ret);

ret = -EIO;
goto err_free_mem;
goto err_failed;
}

/* Initialize an instance of the shared memory service. */
Expand All @@ -676,7 +676,7 @@ static void vc_sm_connected_init(void)
__func__);

ret = -EPERM;
goto err_free_mem;
goto err_failed;
}

/* Create a debug fs directory entry (root). */
Expand Down Expand Up @@ -722,8 +722,7 @@ static void vc_sm_connected_init(void)
debugfs_remove_recursive(sm_state->dir_root);
err_stop_sm_service:
vc_sm_cma_vchi_stop(&sm_state->sm_handle);
err_free_mem:
kfree(sm_state);
err_failed:
pr_info("[%s]: failed, ret %d\n", __func__, ret);
}

Expand All @@ -732,7 +731,7 @@ static int bcm2835_vc_sm_cma_probe(struct platform_device *pdev)
{
pr_info("%s: Videocore shared memory driver\n", __func__);

sm_state = kzalloc(sizeof(*sm_state), GFP_KERNEL);
sm_state = devm_kzalloc(&pdev->dev, sizeof(*sm_state), GFP_KERNEL);
if (!sm_state)
return -ENOMEM;
sm_state->pdev = pdev;
Expand Down Expand Up @@ -766,7 +765,6 @@ static int bcm2835_vc_sm_cma_remove(struct platform_device *pdev)

/* Free the memory for the state structure. */
mutex_destroy(&sm_state->map_lock);
kfree(sm_state);
}

pr_debug("[%s]: end\n", __func__);
Expand Down

0 comments on commit 8652e3e

Please sign in to comment.