Commit dd906cc6 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul

soundwire: intel_init: use devm_ allocation

Make error handling simpler with devm_ allocation.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20200531182102.27840-5-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 9cd1c5a7
...@@ -42,9 +42,6 @@ static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) ...@@ -42,9 +42,6 @@ static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx)
link++; link++;
} }
kfree(ctx->links);
ctx->links = NULL;
return 0; return 0;
} }
...@@ -96,14 +93,15 @@ static struct sdw_intel_ctx ...@@ -96,14 +93,15 @@ static struct sdw_intel_ctx
dev_dbg(&adev->dev, "Creating %d SDW Link devices\n", count); dev_dbg(&adev->dev, "Creating %d SDW Link devices\n", count);
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); ctx = devm_kzalloc(&adev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx) if (!ctx)
return NULL; return NULL;
ctx->count = count; ctx->count = count;
ctx->links = kcalloc(ctx->count, sizeof(*ctx->links), GFP_KERNEL); ctx->links = devm_kcalloc(&adev->dev, ctx->count,
sizeof(*ctx->links), GFP_KERNEL);
if (!ctx->links) if (!ctx->links)
goto link_err; return NULL;
link = ctx->links; link = ctx->links;
...@@ -146,9 +144,8 @@ static struct sdw_intel_ctx ...@@ -146,9 +144,8 @@ static struct sdw_intel_ctx
return ctx; return ctx;
pdev_err: pdev_err:
ctx->count = i;
sdw_intel_cleanup_pdev(ctx); sdw_intel_cleanup_pdev(ctx);
link_err:
kfree(ctx);
return NULL; return NULL;
} }
...@@ -216,7 +213,6 @@ void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res) ...@@ -216,7 +213,6 @@ void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res)
void sdw_intel_exit(struct sdw_intel_ctx *ctx) void sdw_intel_exit(struct sdw_intel_ctx *ctx)
{ {
sdw_intel_cleanup_pdev(ctx); sdw_intel_cleanup_pdev(ctx);
kfree(ctx);
} }
EXPORT_SYMBOL(sdw_intel_exit); EXPORT_SYMBOL(sdw_intel_exit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment