From patchwork Sat Jun 17 08:09:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Shao X-Patchwork-Id: 109432 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1852139vqr; Sat, 17 Jun 2023 01:28:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XsfaKl1oYnw1FpP4scbz9u/D/04Z51GsFPN3UoE+x9w2MWcQk83d94d4arsmDj8vWYT8E X-Received: by 2002:a92:c943:0:b0:342:d7b:4667 with SMTP id i3-20020a92c943000000b003420d7b4667mr2028523ilq.16.1686990499443; Sat, 17 Jun 2023 01:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686990499; cv=none; d=google.com; s=arc-20160816; b=z/twjgoSVzbo6yW4Qel41jQxabOklodNNUL2+l1pmsicNM2ZoiwjQhgqB8NdUUCyB3 uYK8wkMJUk6Q1rpNHOuchUDm+eKiW95bEYYrRpksChz5AcDFraiINRj6BrdPde+H4NvF SVTp7H/IdJ/Cne8njIw08F15BMLi5RXB6TB8eBCSNgxz28yfHSiIcnmrWF+/5LQXW++5 B6RlrqJIkpKqhxwdI98D1k3YMGzgKGB4XtuYEbIzgr5g6W7qb8/4E6/fOF2EJ2dICGLK oaUHF50Su6l54lGiivb3p25ZsgNIuIf447yHinO/2K4hBgDdFVVtdQXEHB61XfQy1R+v eCNQ== 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=iO7yYZHdApPLayvlEq96oV4J2Y5un4PdapCLJrNW4Uo=; b=NMmZQkfo7nGeOlFxAXABY+K72FcOEX9JP/w6UJK+ycIRyuauKuwc7TjHaTW2ObbB0L hLu/nvyNofQBRs8rugFRAuJnh080/ybdGbqv+G2V7hZ0GbJ/xgU0exuH0gZOO9kyA9fY SfdGUJ8ZhWWOxieIp6IVwvMlfR1iC9Vl8oZ0GN7bt0tW7/t0tDTvIBLhHXxORVI4bRHZ 2xXeEtHKElvse+Uy/jPVEXUriVX+igSXenSXyHPWRZHLspw3MkMM1iGhOf2ITQOyh5TX JEzeevVHXVd9g1T8ZGBlfTf+uDEipgUJ4q5BxaeIhnXBqt/C1CcgsWFxS3rSoWIBOfEb lrhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NoD8C8BV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a639d0a000000b005440e9ee0b2si13352817pgd.569.2023.06.17.01.28.04; Sat, 17 Jun 2023 01:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NoD8C8BV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346274AbjFQIJ4 (ORCPT + 99 others); Sat, 17 Jun 2023 04:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346299AbjFQIJy (ORCPT ); Sat, 17 Jun 2023 04:09:54 -0400 Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 210CF1BDF for ; Sat, 17 Jun 2023 01:09:53 -0700 (PDT) Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5704ddda6dfso19139517b3.1 for ; Sat, 17 Jun 2023 01:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686989392; x=1689581392; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iO7yYZHdApPLayvlEq96oV4J2Y5un4PdapCLJrNW4Uo=; b=NoD8C8BVIiciXMn2EjslqtsdVtrK3ecA1gC8tOPLR/c0iJOSaaAilbSxUznSxPVnry Hf1nLe4Wno8ZjBYPTtiptNdAjBt48QyjXi18yYVqNvNSSgF1fqLCuKWfj9sHlFKv0VsL +7VvP6uqMk5IVXslMyiQXzmVXR6b2aSIKoM0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686989392; x=1689581392; 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=iO7yYZHdApPLayvlEq96oV4J2Y5un4PdapCLJrNW4Uo=; b=kHWjSiO6A1VhkDV+ULIP9pkDa3+NIvPJNxhYRN/PshZxSe6J4tZStv9Cx8TivChdNK MJkpOF/lkILm82w/CMPNSkHRYhf6TktzEvbR1hNJyX4Hx5tscn7hQ9/ck3A3eQZnDatN kkE7Anez2EX5He3ZmwXQBaGT8N3KOWl1+5k1nF5rewTPcTYKS8eGPI6mb/2E8F2lEuYC 0/M4IWiLclHySKkIarSP7WlgGYnm+FROWD+rD95U21A7X/dtM+bhQ3XU125K6wYTcZ0J BeBN9xtyI2hy2zrGsXUwG+MZKuQBV3KpfpcME4WEhoBadpL30kdpiBHsPEVNZo6Yn60K Owog== X-Gm-Message-State: AC+VfDzH5HT+weXFtcUTEi0ZWCGssdrVGDWdmDaNEpnpAgQFDiGLDWCS JumUEPrC0sgxNyQngj0wT0px9w== X-Received: by 2002:a0d:d8c2:0:b0:565:8c16:a0e1 with SMTP id a185-20020a0dd8c2000000b005658c16a0e1mr5223821ywe.13.1686989392392; Sat, 17 Jun 2023 01:09:52 -0700 (PDT) Received: from fshao-p620.tpe.corp.google.com ([2401:fa00:1:10:f83b:769f:1443:112]) by smtp.gmail.com with ESMTPSA id c4-20020a170902c2c400b001aaf536b1e3sm8476488pla.123.2023.06.17.01.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 01:09:51 -0700 (PDT) From: Fei Shao To: Stephen Boyd Cc: Fei Shao , Jerome Brunet , Michael Turquette , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: Fix memory leak in devm_clk_notifier_register() Date: Sat, 17 Jun 2023 16:09:01 +0800 Message-ID: <20230617160901.1.I2b151cdf7a72d9e3ecc7ab2ff38409ebe6d65d6b@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768937749959375710?= X-GMAIL-MSGID: =?utf-8?q?1768937749959375710?= devm_clk_notifier_register() allocates a devres resource for clk notifier but didn't register that to the device, so the notifier didn't get unregistered on device detach and the allocated resource was leaked. This fixes the issue. Fixes: 6d30d50d037d ("clk: add devm variant of clk_notifier_register") Signed-off-by: Fei Shao --- drivers/clk/clk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 7ac9f7a8cb84..c249f9791ae8 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -4741,6 +4741,7 @@ int devm_clk_notifier_register(struct device *dev, struct clk *clk, if (!ret) { devres->clk = clk; devres->nb = nb; + devres_add(dev, devres); } else { devres_free(devres); }