diff mbox

drm/tegra: sor: Double free on error

Message ID 20160704074501.GA4849@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter July 4, 2016, 7:45 a.m. UTC
"brick" is allocated with devm_kzalloc() so freeing it with kfree()
leads to a double free.  We can just delete it.

Fixes: a7ba8310c7f5 ('drm/tegra: sor: Implement sor1_brick clock')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Alexandre Courbot July 6, 2016, 2:17 p.m. UTC | #1
On Mon, Jul 4, 2016 at 4:45 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> "brick" is allocated with devm_kzalloc() so freeing it with kfree()
> leads to a double free.  We can just delete it.

That makes perfect sense.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
diff mbox

Patch

diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 8425eda..e750ced 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -345,7 +345,6 @@  static struct clk *tegra_clk_sor_brick_register(struct tegra_sor *sor,
 {
 	struct tegra_clk_sor_brick *brick;
 	struct clk_init_data init;
-	struct clk *clk;
 
 	brick = devm_kzalloc(sor->dev, sizeof(*brick), GFP_KERNEL);
 	if (!brick)
@@ -361,11 +360,7 @@  static struct clk *tegra_clk_sor_brick_register(struct tegra_sor *sor,
 
 	brick->hw.init = &init;
 
-	clk = devm_clk_register(sor->dev, &brick->hw);
-	if (IS_ERR(clk))
-		kfree(brick);
-
-	return clk;
+	return devm_clk_register(sor->dev, &brick->hw);
 }
 
 static int tegra_sor_dp_train_fast(struct tegra_sor *sor,