Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1238dc47 authored by Atul Raut's avatar Atul Raut Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: smem: Fix memory leak



In case of Hibernation we are calling probe twice
once in thaw and in restore but we are not freeing
the allocation in freeze callback, causing
possible memory leak.
Fix by freeing allocations.

Change-Id: If0be8de534e21ac6349279ba0f53dd9b2f3e30d1
Signed-off-by: default avatarArun Prakash <app@codeaurora.org>
Signed-off-by: default avatarAtul Raut <araut@codeaurora.org>
parent a32cdfec
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2015, Sony Mobile Communications AB.
 * Copyright (c) 2012-2013, 2017, 2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2013, 2017, 2019-2020 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1053,6 +1053,12 @@ static int qcom_smem_probe(struct platform_device *pdev)
static int qcom_smem_remove(struct platform_device *pdev)
{
	hwspin_lock_free(__smem->hwlock);
	/* In case of Hibernation Restore __smem object is still valid
	 * and we call probe again so same object get allocated again
	 * that result into possible memory leak, hence explicitly freeing
	 * it here.
	 */
	devm_kfree(&pdev->dev, __smem);
	__smem = NULL;

	return 0;