Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4427406rdb; Mon, 11 Dec 2023 21:14:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmVkFwkirP8d2E7ho/YquZd2kjaZQDv/AGErgd6iYEMRXUSJverJLVlkflWzzGvp//q4wg X-Received: by 2002:a05:6a20:1047:b0:190:fca:72d8 with SMTP id gt7-20020a056a20104700b001900fca72d8mr6418788pzc.109.1702358041813; Mon, 11 Dec 2023 21:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702358041; cv=none; d=google.com; s=arc-20160816; b=RnGIcEGAG8IGxxWEcrUy+2WPh2KvB+w2yDEyyzSbjuD65NzqwrV8zPJwq0l+7X59hM D0tY4t8kVlUfiz27IVw1H+Rh22PsHV64ICIqZ1DfBQBo4D9/RhSxmjwqP0F29SkRdDp8 5Zh9z6RF6nrzhf0byVfX4y+wZqhYvPDj6e48ccYzv/9Bs3VtUXMvQRD36ml0zs0gFDVz o3lnr4Rk4UpSwVJTDIOD++btVF7sUk5hfV1Sk3un/d5Z3YVFnF6zEJTnrfqbDIUM5Sby evOd16/7+OShPIKzLYfxIkRx5KTZ45miPvi/xyj9ybUXBSgIm6/aW60DIojvhUA4RzFv orDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tXIcMpYll8QMceVFY3rp9zqkWtsVCCZScS2K9YJ4lgc=; fh=b+U11BBuKeV++qQt7shLaL20eqy9FH+qlcNzUZMrQvM=; b=YaW/mDBhmhhs3tHokbp1YeSWxFDt5JZOVFWiT9C0Nkeg7amCvr2/pXIrrxVoP3ZfZA wXEkzQq29qHsEsqCZ0Jsi6RJjetOaW3sksJQdnhlVM2UH2VI00BxuKM5KntdbHKzfF88 HvWwoAhKUV1tJ694VBcy3IxqjjhdM4ehJ0NEGrOzQtpNWQIyCDRIu/esaH/6lf99USr6 rwVmkfb1a+Yc1kgmVfegGqlr6aYcTjTxCA10HLv07BGqHYbnGM16HsSOlHaV1s3oxQCR uHQsrg/jhFzd4uo2asdy9uzLwH1iNiCkeSMS2gI+1h0d9/z53gneo4c32vLGnV43wpY3 Urhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IOkooV6Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s42-20020a056a0017aa00b006cec77b95a3si7136932pfg.279.2023.12.11.21.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 21:14:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IOkooV6Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 7B14080579BE; Mon, 11 Dec 2023 21:13:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229536AbjLLFNq (ORCPT + 99 others); Tue, 12 Dec 2023 00:13:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjLLFNp (ORCPT ); Tue, 12 Dec 2023 00:13:45 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEBE8CE; Mon, 11 Dec 2023 21:13:51 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2886d445d8dso1465827a91.1; Mon, 11 Dec 2023 21:13:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702358031; x=1702962831; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tXIcMpYll8QMceVFY3rp9zqkWtsVCCZScS2K9YJ4lgc=; b=IOkooV6Qh497DR4J1MMKsD/U1Eei6Xv3gCGW6k/hHiLhew0Nsa/Vgn+4pAgA3sKnP7 MMx55m4LwdOBhwMpjJkFwx4WaVHNydcy11Uc90mZZTVGaZBBQGYztDRPmnsSy+co3xff xVfujwlzDYhF1R1uui3e7mAGVR3Pc/cPkelZ5P2KBfrwjZbVWzJpSDonWYgwCC7G+Q1j 1Eb8n0ehgPK+Udt9CDeAONI4R1HbcrJAVS+QHEmR8pMnYHDX17sL4BPZ2Nb5kVXw9kkG t4cIoIUX5F+kHVA9z9fjyYqN0yxXDAZamhHCfJNGv0J+v61X9MVAEArV0w/dff8gvpXf IqLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702358031; x=1702962831; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tXIcMpYll8QMceVFY3rp9zqkWtsVCCZScS2K9YJ4lgc=; b=u0KagUg+2GCt3ackTrn/r5hTWYTI+nc2iWSO7+ZL6f8UmpXYayfdWic13kZ/BwQZzF izVqTyWkLJzgreGMCE/vFf/XeFqC0BAlEsFx1thODrcf4Czvd7UiocV0BDg9KuMbnwwh MfS91M0VW3LlkW+KciJ/MvOxHp6/nEP7+ZKS79kNjH8dWxc7eXFb7iP2wFWNz8/UW0r9 w9axnacwh7Qz3Kph+EZmrbXko+vSFtoWCTBeJEMrf9XVO+VmXSiUoMUKi2denqE1NlHr TQ8NKaz+BgWOEdlQY92JgqKWYxQ/cXsAKRoAugv068m7qM31tka0mYByfbqw+1NVEqUD SVtA== X-Gm-Message-State: AOJu0YwLHEdJO3vkInn0eXb0Z7EBcBf7ZOhg5e0IygbrtOoAuVtTF/hB GF/B5bcgGvla/fx13l4hgyZSUg61750= X-Received: by 2002:a17:90b:3a82:b0:283:5405:9e90 with SMTP id om2-20020a17090b3a8200b0028354059e90mr9522563pjb.3.1702358031001; Mon, 11 Dec 2023 21:13:51 -0800 (PST) Received: from visitorckw-System-Product-Name (IP-216-168.cs.nctu.edu.tw. [140.113.216.168]) by smtp.gmail.com with ESMTPSA id pl16-20020a17090b269000b002859a1d9fb7sm7948081pjb.2.2023.12.11.21.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 21:13:50 -0800 (PST) Date: Tue, 12 Dec 2023 13:13:47 +0800 From: Kuan-Wei Chiu To: Conor Dooley Cc: mturquette@baylibre.com, sboyd@kernel.org, duje.mihanovic@skole.hr, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk: mmp: pxa168: Fix memory leak in pxa168_clk_init() Message-ID: References: <20231210175232.3414584-1-visitorckw@gmail.com> <20231211-urgent-carol-45ca352a9d2a@wendy> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231211-urgent-carol-45ca352a9d2a@wendy> 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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 11 Dec 2023 21:13:59 -0800 (PST) On Mon, Dec 11, 2023 at 01:19:17PM +0000, Conor Dooley wrote: > On Mon, Dec 11, 2023 at 01:52:32AM +0800, Kuan-Wei Chiu wrote: > > 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 > > I dunno why you have CCed me on this tbh, I guess I must have acked a > patch related to this driver's bindings somehow. > I included you in the CC list based on the results from ./scripts/get_maintainer.pl, which listed your email. I apologize for any inconvenience. I will be more careful in selecting the recipients for my patches in the future. > I wonder, is there actually any point in freeing these, isn't the system > going to fail to actually boot if these allocations fail? > I'm not familiar with the boot process. I noticed similar cleanup in related code (e.g., clk-of-pxa1928.c) and thought it might be an oversight in pxa168. If releasing memory here isn't essential, I'm inclined to drop the patch. However, if the cleanup is necessary, I believe additional iounmap, similar to commit 19b9f29 (clk:mmp:clk-of-pxa910: Free memory and Unmap region obtained by kzmalloc and of_iomap), may be required. If necessary, I'm willing to send a v2 patch with the additional changes. Best regards, 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 > >