Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp390267rdb; Mon, 22 Jan 2024 07:22:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWdp9SiZifjeSB7xqdjjFLQHwgl9gCGjfWmQrMA8NNYWAJ3BL0X5ZJoq7Ixh4IINozyLmA X-Received: by 2002:a05:6214:20a8:b0:680:fe0d:28dd with SMTP id 8-20020a05621420a800b00680fe0d28ddmr5392074qvd.14.1705936968641; Mon, 22 Jan 2024 07:22:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705936968; cv=pass; d=google.com; s=arc-20160816; b=sqFWBaXSP/OOnOeJLxEqMPd6cgFq7ihIm7XlO5uBFqFAGEANjYao1W0kuofyohhQk0 pqikWu/CobmwA8fIAaVmQ+LNfr/sj2OZGBDsC7OPjhxEfdZbrZyQrgWeCPAbm9VBR6tv KzlJ/UtPJQVB5PHCvAvaWFvufCuZOFVjVvqhv5x4+lMya+kwzHAWj6Z8fdd4q/BjG4O8 y7DYRqcz9jitegmlBlZMpQmaoR0mzXqeggiW2PK6cGjQot6k2zXe+Fi5ivI/yiRjSKuh 0pa17dVnVL3tT8lVG/AaFhOaFUgv1Le2Ggj8HWDyH8FgMEEmtrh2g42WKzlReMyy7fiG VhMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=A4qYOmcmd/xJqWiQtNBneaIOvV1WZYZITx1XDEKz8Ms=; fh=M4sPd7ZhkYOIA2LCOLjI4wazGKPW1fgTZyVUM20tkpk=; b=RTB5KX+ogUtIvV54Vyk3z8Va0KLJTWQEHhbNu8NfytTyqPBeZIwYHHdEhkiI3Cc65H r0KRGVBY+ti7HQ535w4tSyy6TxiClPzfCk9LhP6aG3DP5fDglfBeT00iTben3OnM4Vtn wFqi96/lWhjyiZA5Xzi8TZXpK4OWBrT8IzL9IP7ng+QNaZutdoE1ZL2+akg/umxXdUOi rwGCKj3pYlRu9GwSqcMlmhdP2gIJPjixX9G9f2nXPiDVovpeqVMH6QDpXsx9C6oZSgGU a0vaOseFVftZVdAOjoZreiOPQjUZjTkRWg5u0SAWltGThHjXE2xXHBzauAOyZlhLIxC/ 0hiA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kZpNLkNB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i2-20020a0cf382000000b006818f0b3569si5844592qvk.182.2024.01.22.07.22.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 07:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kZpNLkNB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 65B361C22B08 for ; Mon, 22 Jan 2024 15:22:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E60F5B5C8; Mon, 22 Jan 2024 14:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kZpNLkNB" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A83095B5B5; Mon, 22 Jan 2024 14:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935598; cv=none; b=Bjx4wWKPLkTp/FURnN2IXEaMZgjUmlTRTXBV5ZEJnClk7Yz/M/DYJj0Gi87HyAxwiBlmcoVgilJPYZQnsVh7ZHZQXn0XqOh+4eUILH3SZ2LgXZzR6smnBSkjwRjWRAoVOrOdo5fYyoYwWUryC0dxJgHWSI/qQwVYAC+R4NrmaYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935598; c=relaxed/simple; bh=gi/zS+FijJoacGOzitI9u1y72nJ7iavRiUxAwlBWS9s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n81xX3Nshg0/BJleizj6SnpkevfmYCHLec+Y8H5gg8YtbJQYh8gdH2zp5VtaxhuwRpwCNU84JT15lIqEGZH81RATtcA49YtkkKE5olnAN8WYXF3RdjAMRHpcSQ5Y0sMM5EUxJJhuIHBpWNGZKKlRIbT/WYlvPn+M8+ede57LE1Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kZpNLkNB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68C7AC43394; Mon, 22 Jan 2024 14:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705935598; bh=gi/zS+FijJoacGOzitI9u1y72nJ7iavRiUxAwlBWS9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZpNLkNBoACItLuRQxurK1cVKfDWora97NdigFlPqST/Z7VOI9VXIlCCjSadF4AT3 Vt7H4VgNwFxAVukK1G/GGaTSvX7kP6NfzFRSJs43dN+na1ErT4+uJrWPXPxX/deN5h 4IqthMVrTmdJ7v7vWLnAszY/ylOKjy0/iAC9Xo6q4R3yEOteZs7chkFbA53vLz4L8q ozAwNWWgmadUahcnshs98MZNSzHzeTgughisyyi24VbnXBjdf6G9xU6FxtKiDOMuOl zFAaX/FSrnetY2Av+YfizlgQusMmZWhqrJ2v6WxY0oSNPvpR6BMENw+89A06ycTvMd 7k6UhoYe+haeg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kuan-Wei Chiu , Stephen Boyd , Sasha Levin , mturquette@baylibre.com, duje.mihanovic@skole.hr, conor.dooley@microchip.com, linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 6.7 60/88] clk: mmp: pxa168: Fix memory leak in pxa168_clk_init() Date: Mon, 22 Jan 2024 09:51:33 -0500 Message-ID: <20240122145608.990137-60-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122145608.990137-1-sashal@kernel.org> References: <20240122145608.990137-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.1 Content-Transfer-Encoding: 8bit From: Kuan-Wei Chiu [ Upstream commit 2fbabea626b6467eb4e6c4cb7a16523da12e43b4 ] In cases where mapping of mpmu/apmu/apbc registers fails, the code path does not handle the failure gracefully, potentially leading to a memory leak. This fix ensures proper cleanup by freeing the allocated memory for 'pxa_unit' before returning. Signed-off-by: Kuan-Wei Chiu Link: https://lore.kernel.org/r/20231210175232.3414584-1-visitorckw@gmail.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/mmp/clk-of-pxa168.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/mmp/clk-of-pxa168.c b/drivers/clk/mmp/clk-of-pxa168.c index fb0df64cf053..c5a7ba1deaa3 100644 --- a/drivers/clk/mmp/clk-of-pxa168.c +++ b/drivers/clk/mmp/clk-of-pxa168.c @@ -308,18 +308,21 @@ static void __init pxa168_clk_init(struct device_node *np) pxa_unit->mpmu_base = of_iomap(np, 0); if (!pxa_unit->mpmu_base) { pr_err("failed to map mpmu registers\n"); + kfree(pxa_unit); return; } pxa_unit->apmu_base = of_iomap(np, 1); if (!pxa_unit->apmu_base) { pr_err("failed to map apmu registers\n"); + kfree(pxa_unit); return; } pxa_unit->apbc_base = of_iomap(np, 2); if (!pxa_unit->apbc_base) { pr_err("failed to map apbc registers\n"); + kfree(pxa_unit); return; } -- 2.43.0