[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200531182102.27840-5-yung-chuan.liao@linux.intel.com>
Date: Mon, 1 Jun 2020 02:21:00 +0800
From: Bard Liao <yung-chuan.liao@...ux.intel.com>
To: alsa-devel@...a-project.org, vkoul@...nel.org
Cc: vinod.koul@...aro.org, linux-kernel@...r.kernel.org, tiwai@...e.de,
broonie@...nel.org, gregkh@...uxfoundation.org, jank@...ence.com,
srinivas.kandagatla@...aro.org, rander.wang@...ux.intel.com,
ranjani.sridharan@...ux.intel.com, hui.wang@...onical.com,
pierre-louis.bossart@...ux.intel.com, sanyog.r.kale@...el.com,
slawomir.blauciak@...el.com, mengdong.lin@...el.com,
bard.liao@...el.com
Subject: [PATCH v2 4/6] soundwire: intel_init: use devm_ allocation
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Make error handling simpler with devm_ allocation.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@...ux.intel.com>
---
drivers/soundwire/intel_init.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index e87f17240547..f9d190157c47 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -42,9 +42,6 @@ static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx)
link++;
}
- kfree(ctx->links);
- ctx->links = NULL;
-
return 0;
}
@@ -96,14 +93,15 @@ static struct sdw_intel_ctx
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)
return NULL;
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)
- goto link_err;
+ return NULL;
link = ctx->links;
@@ -146,9 +144,8 @@ static struct sdw_intel_ctx
return ctx;
pdev_err:
+ ctx->count = i;
sdw_intel_cleanup_pdev(ctx);
-link_err:
- kfree(ctx);
return NULL;
}
@@ -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)
{
sdw_intel_cleanup_pdev(ctx);
- kfree(ctx);
}
EXPORT_SYMBOL(sdw_intel_exit);
--
2.17.1
Powered by blists - more mailing lists