Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp299646lqt; Thu, 6 Jun 2024 04:12:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU84fMUswYLhTwdoi1o9ib2m162KNtG5j9z48CdC6wj/8q1YCniUDIq4wphHm3ikFHWGzLlX0bf+0eKlRkeQeamaitEIEso9WIehh2jJQ== X-Google-Smtp-Source: AGHT+IF2b1IhuGmAI19j6h0Zaq2oHV+37g5dxVETWizvb6uYhLLSRSdVFzEepLh5A8vZn4SOWwp3 X-Received: by 2002:a17:902:bb87:b0:1f4:afa4:eb18 with SMTP id d9443c01a7336-1f6a5a0e7b6mr55581185ad.17.1717672334461; Thu, 06 Jun 2024 04:12:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717672334; cv=pass; d=google.com; s=arc-20160816; b=J0yulY5tgoEa9P0LY+lqW+lZZjj3GDjIXyw7pe0d6xH1g4UUKcE+c2gfpPz1w3scdU JY6+z4jdTVDB5G26Spm511/4gIr/eHG8WiHXLwQzWbmDuJy+TZWNK4GBmJHhgyoyNcmn JP5ABsHKuVD2pQXEhxj0WClV3aMTDOB48eDJNTrDcnQNOof9/2pvZcOm8Ul7AjFePuQr MuPRgsfIUSYEHK/IvTgYcOu3n+wE9ulU9uP3lKpIcjigl3rQp/m2kAlMHLhVFf6CLaaw r/8rXqEIqs2dl/fSiuWAB8i/Lf9AA8AecoM4nG8BMMqqAuDMyla+tDGNtkbv0RVLexe6 v97Q== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=vVnZyr+Byd5IfmgdNdhgTlifSMH3+cJybEmR3qMbFvM=; fh=+JUhw+it9PEL1LOrWcRzout28CIk2/dnLUb6nThxfVw=; b=PMsgqNvu5DN3iKxeBKfjsDnovy3FVvRLQzvdtik3fW9WFQ028+ApRzcpcFx1GAjxF7 BNusdsaCw4Aj91O8oTQrJ7JL9ntn2ifNPlwb1cljHcRXJTfvGtvaM9qYNPxy6E2ITJbb JxSXlu06ZjHYwvSmLDq5G4W8Htdi1JdeYQyCcid4hFPHpto7j7dvV3/RBY0c3pOwahTy S1ls30YrVyPhHwyzOU6pqHt7nkxf1XVyeJrappsOLm3Ma8jvj2r2RIKuI1OKE1AQQkUf SCB6c/WRgfKGagwbsYLcnjFtlz9EIni1HEQSX060CvLvw8Ucelytth+PR6seBCDvp5ct 8M6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=a74KY71h; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-204158-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204158-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd832433si9590265ad.640.2024.06.06.04.12.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 04:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204158-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=a74KY71h; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-204158-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204158-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BBEB287455 for ; Thu, 6 Jun 2024 11:12:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F8C61953A5; Thu, 6 Jun 2024 11:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b="a74KY71h" Received: from mx1.t-argos.ru (mx1.t-argos.ru [109.73.34.58]) (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 C1D5D1870; Thu, 6 Jun 2024 11:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.73.34.58 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717672325; cv=none; b=bd+rtl8jvStjvW2MW4DlW3b/PsV3YHLLo4/8qJ2vE5sV7nuD7C1xkNdMOgwxEVBpOp6udNKIeWhRqaohF7bbNtBvCqE324OcDrgzR0Yle+GqGZdvj3p/4FhdbGXFdpVMhV+Qs1surCF93E+KLVaJ6jdEo4dC0rEf7lshrXzZ7N0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717672325; c=relaxed/simple; bh=xkdQLPprwdUTlYoPH0s01hFUilN1bSyGE+rTC2MwfuQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Gbf4scbMZMNzxA+K6GggpKSyZj7Nmmtm5K1TsONenRA5KX5MSasw9WouEDtMndENafDx9Z/Y67ECQZl+Dc6aM5eFFO65HGbGDHPaZeUElKfcKhHv47K9tdkmY3t9hWAF7RtmsNtNOg+ZEgv+P1UBMa+bHtoDEU9JJL839aDSmRg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru; spf=pass smtp.mailfrom=t-argos.ru; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b=a74KY71h; arc=none smtp.client-ip=109.73.34.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=t-argos.ru Received: from mx1.t-argos.ru (localhost [127.0.0.1]) by mx1.t-argos.ru (Postfix) with ESMTP id 25990100003; Thu, 6 Jun 2024 14:11:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=t-argos.ru; s=mail; t=1717672303; bh=vVnZyr+Byd5IfmgdNdhgTlifSMH3+cJybEmR3qMbFvM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=a74KY71hgI+3T00Tg8UGiiq6XsAW2C7aRMPQe/Jz2QqMquL8glRnElIe9XXpYu418 hf6G3bFaNnv77YZxubbWhCcNbDE5E08Nvyha6yDPyasrBIW3nh3nMrc9z4m7G62E0n IOgCxnhTma+plhiq4Mw9+wfQvn2JbpEEnQDh6QDpKdQcpCz7ORfVKfBgl8mF6dyWbV wY4TYuTFQHVSaskRHKjVbygOWck7Fk3aYyTOS4ConnUgVlK4X2MaaogczHE/G6+s6H gK32mQrUDQhIWLX0Qf+Ct5XWN+98XIpkVryf4lFtAFUs1Wbk1H4kw4Vrcacnwfq3vk gTe9ST+JxB1fw== Received: from mx1.t-argos.ru.ru (ta-mail-02.ta.t-argos.ru [172.17.13.212]) by mx1.t-argos.ru (Postfix) with ESMTP; Thu, 6 Jun 2024 14:10:23 +0300 (MSK) Received: from localhost.localdomain (172.17.215.6) by ta-mail-02 (172.17.13.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 6 Jun 2024 14:10:03 +0300 From: Aleksandr Mishin To: Weiyi Lu , , Greg Kroah-Hartman CC: Aleksandr Mishin , Michael Turquette , Stephen Boyd , Matthias Brugger , Sasha Levin , AngeloGioacchino Del Regno , Markus Schneider-Pargmann , , , , , Subject: [PATCH 5.10/5.15/6.1] clk: mediatek: Add memory allocation fail handling in clk_mt2712_top_init_early() Date: Thu, 6 Jun 2024 14:09:55 +0300 Message-ID: <20240606110955.35313-1-amishin@t-argos.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ta-mail-02.ta.t-argos.ru (172.17.13.212) To ta-mail-02 (172.17.13.212) X-KSMG-Rule-ID: 1 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 185766 [Jun 06 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: amishin@t-argos.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 20 0.3.20 743589a8af6ec90b529f2124c2bbfc3ce1d2f20f, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;mx1.t-argos.ru.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;t-argos.ru:7.1.1, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2024/06/06 10:23:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2024/06/06 06:58:00 #25471362 X-KSMG-AntiVirus-Status: Clean, skipped No upstream commit exists for this commit. The issue was introduced with commit e2f744a82d72 ("clk: mediatek: Add MT2712 clock support") In case of memory allocation fail in clk_mt2712_top_init_early() 'top_clk_data' will be set to NULL and later dereferenced without check. Fix this bug by adding NULL-return check. Upstream branch code has been significantly refactored and can't be backported directly. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Aleksandr Mishin --- drivers/clk/mediatek/clk-mt2712.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/clk/mediatek/clk-mt2712.c b/drivers/clk/mediatek/clk-mt2712.c index a0f0c9ed48d1..1830bae661dc 100644 --- a/drivers/clk/mediatek/clk-mt2712.c +++ b/drivers/clk/mediatek/clk-mt2712.c @@ -1277,6 +1277,11 @@ static void clk_mt2712_top_init_early(struct device_node *node) if (!top_clk_data) { top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); + if (!top_clk_data) { + pr_err("%s(): could not register clock provider: %d\n", + __func__, -ENOMEM); + return; + } for (i = 0; i < CLK_TOP_NR_CLK; i++) top_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); -- 2.30.2