Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3544995rdb; Sun, 10 Dec 2023 09:52:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEOEPl2FJODA1QriREu/zqj92N1RVRf/eQ4PFHVDkeDYTkhz1LAtOnDicae3NlALlYPB9X X-Received: by 2002:a05:6a20:6a1f:b0:18f:f5b2:a891 with SMTP id p31-20020a056a206a1f00b0018ff5b2a891mr4592345pzk.86.1702230777421; Sun, 10 Dec 2023 09:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702230777; cv=none; d=google.com; s=arc-20160816; b=lU8JIzwsx4azPXUowbeXRj+P3HnbNskV0x2xNCTmSyS2SUAYJfoNyTRrx6hyIwVUJL 4R6JcHypQG8B0Bz5Q7Hez/skXUUX5ObABh5iRBzRryOkimvDpwufeHEw2HXZmAQsNYPj 4Gi16m0U/mMNxhJnyF9L5QYsRC328uAsbqrYQdT84ToojV9u8laowMRfm0/ZPecvRc97 KShepxliqmmfqSdUpb7O7Wg5UH4tDRbRLo4hxvApQBHzM5qZDkxNMcv7OxlSLPDfNoFG PH9LQnNEoD8Gi6oDTa8nORIDvNWg9p6t31KD++ZdfZ4X3ihBIU2TOyyOlReLzfqO7IdQ Ll0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8/xSfRIfAoE+xV2upe+TlMguoR16jHyW0kjGiJ1WVl4=; fh=6+jqw78CmU4IvVDYMoHCV5/4iG8P7IF9qgWUrY3cymE=; b=TbElxP/tRG4LX5poQOVKaUyqxkxNQgnuTAMtiJq/sFqfVSZN4FIe1tEAalAiHPKP9h hXJl3Dt6jdCxgGj/9hIfrz4TP4sLzH/aQbR4nX3yr1ro3Ls+uV5WY7iqhQaDZMp9p0sU 1yQFsg0xy8kae6FO4JNH9NMDXtaWBa3R1ixJOrbAqbHTDorxJTToDEbWIETmtSoiEX2i 00PPURU4VwZubYZjJ+R233tXS2tdoR7KiDBlH0OSxtqCtmvg6+RT4dakNSn92AJnyUcy bEOjgHP2nImr9VLU9uuA1RbMb1oBaYY9ixwcsiw/o34PRm/u+ucWKEzpjXcOllSqR3wi x2Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m3soUrjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m12-20020a056a00080c00b006cea5b0c565si4886154pfk.282.2023.12.10.09.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 09:52:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m3soUrjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 06A23807501E; Sun, 10 Dec 2023 09:52:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231916AbjLJRwm (ORCPT + 99 others); Sun, 10 Dec 2023 12:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjLJRwl (ORCPT ); Sun, 10 Dec 2023 12:52:41 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1CE5FA; Sun, 10 Dec 2023 09:52:47 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-55b5a37acb6so644644a12.0; Sun, 10 Dec 2023 09:52:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702230767; x=1702835567; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8/xSfRIfAoE+xV2upe+TlMguoR16jHyW0kjGiJ1WVl4=; b=m3soUrjppBpEEXIPpzqk+qbycV5PtleaxwSZ75/N+SMVeZsU2KftZSonDqjqC9u1SD hV+c+ohS6u7bbnQAqfXqJbjfarAto5yk44vLXdbBJUKTvM1XaYIDeBB6oOCjJS/BV7M3 ydkBs0+f/TKNSUgIwcFK8LW5f2YbjKUNv6Mqd9aULdqhWTltVIpqUwfFBx0Amw8SDTYB hEjjqsdsALwaY8v6NZmeeTgOt6bUZmfkmm0oFV/cQAKxwCkS46jdZ2GgaLB4TJWc3z0p e2s7MdWR4rlCcsT/XQUCnPdcWOmNh9V8d/PagqHlzgBKtcWZSWL3/aqmDF9aQIAMgJgT K/Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702230767; x=1702835567; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8/xSfRIfAoE+xV2upe+TlMguoR16jHyW0kjGiJ1WVl4=; b=U5LX2Dt/fECiEHsg2IF/cmy0FVhcbrMybWvepTJACNVU5B/HUSTkeSsRCIGw403Kjn 1nG9X5SKnBLTpr9ppOAEW7DW5C5vEwlGW7gylcKf4FbLQmkhKCBp0LZ5Pjw0PhwxZes7 5UMQvFSZuD8aqekBfKWOI5lmaFhGIz7BzE1e3nYB8aQDVNmIHCwsel+qpgmFcz+L5d/h 6lk/naWth/BTl5zqNzsBprqL/Pxly3IKz6/wQH1CnqbHnQSgap+WfDlRiJJt0eH8znH1 j8OO7kc5yy4jJaPjsNjBiXBpIIzskapYl/M2soCP6Kd5ezHIbpl/7TeA3nQYpJ+e7Hol ly/w== X-Gm-Message-State: AOJu0YyEFeQ+4JnqGtQdgDWAad+Qj0jqgditiUDyqvUK1m5EvaNMsfBK s9SwkdX9x7kJ9u5R45x9fUE= X-Received: by 2002:a17:902:db10:b0:1d0:bb65:6860 with SMTP id m16-20020a170902db1000b001d0bb656860mr6145197plx.6.1702230767346; Sun, 10 Dec 2023 09:52:47 -0800 (PST) Received: from localhost.localdomain ([140.116.154.65]) by smtp.gmail.com with ESMTPSA id f12-20020a170902684c00b001cfcf0fcc56sm5157868pln.84.2023.12.10.09.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 09:52:46 -0800 (PST) From: Kuan-Wei Chiu To: mturquette@baylibre.com, sboyd@kernel.org Cc: duje.mihanovic@skole.hr, conor.dooley@microchip.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH] clk: mmp: pxa168: Fix memory leak in pxa168_clk_init() Date: Mon, 11 Dec 2023 01:52:32 +0800 Message-Id: <20231210175232.3414584-1-visitorckw@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 10 Dec 2023 09:52:55 -0800 (PST) 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 --- 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.25.1