Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5457532pxu; Tue, 22 Dec 2020 18:38:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPz3juyseYCNzKgtrw8svXhI9CAvdSUUL22s/vpelSo/E6EyWbf4uwdmqXKTt8dDxVSF9y X-Received: by 2002:a17:907:a96:: with SMTP id by22mr21569161ejc.171.1608691124030; Tue, 22 Dec 2020 18:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691124; cv=none; d=google.com; s=arc-20160816; b=tRM63ESmZWmTqNk2NzNNKVd0sCxJ99JjKSvxfIvD4edw1Zxgv7Ekv9CJKfNKrWQofV /TMxMaoB6U8Gk32MC/nC9ug36M72tddncs4nKyr5IAkIK8WYN4oO6gv5n9cGRm+noVbL EoUEr23QpfpiYQqS0VxGpBG3oCD0woccxcWdMAZIoj4GCejUYEaMSOGKGpNQQkM/s9h4 KUuYzABOgjRaCouwLkFdcZ9OqYv5Uzf2AtuwoWNKXT4IUhsshLKlDFghKYXHECPVJXpU meCfVLd7IpF1zLuoAcSwoN3Uyj59JP2G05vfp6+jx9JVG3hKqDJBfBz1+lLhn8RXNS7X yctg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s1kJj/AS5dsXKbUhrRBi1/vdWwx1RPExBZwaQxW0Yyo=; b=VJI8631uMGdP/Hep5vat9EKxfKGzYyNGbKzhsffwWwl30zSG/SojfJb9RUGVTAQ78Z AOGD3V9PwBHQ+XGtJqA0r84mpna0Ro/k/ZfzOm0oBkWrsF9E1d5oDLan3g4mNxgn2AMM F0zf/uAjg8ouXdnoIyx9A7xeLRO3QcgY8vyGs/7j1Ujnpc29f8OxR2H9sZHnT2xsPs9z HJ33tzfLms3T7QBk3xKQ8eIa89OdJ2TMcRi47WV8Cgo7lzOCkYxrrbxErq9OYclYoqhx QXUcVrGkbYiwV39tFrZu6WzVNJntgyCK2yOv9/mW4+05RwYp64yLEmCwhAp0M/rEWQDh ifdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q324Z9kl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nt21si11175192ejb.739.2020.12.22.18.38.22; Tue, 22 Dec 2020 18:38:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q324Z9kl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730756AbgLWCiU (ORCPT + 99 others); Tue, 22 Dec 2020 21:38:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:54022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730138AbgLWCYJ (ORCPT ); Tue, 22 Dec 2020 21:24:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF0E623137; Wed, 23 Dec 2020 02:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690208; bh=J17Ye1tVNmhTMAZKXijNIjI7waSIU7anezzCCWHNJIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q324Z9kls1ppv48JJqo2Kbr05KJAZ2as7eCowFTFgCZJ6A/2Ys3ZDvq2l6pQltHe2 XLWQFsUWRmxbuVF2naQSrEdKkMDrsyqzKzBKz4OSzUT8nXj7slcBhGUHqAwEziQzG6 pv+LjYJbsjAOxV9yEYk9hABKJsMwIVBN1fSrTE8+p8O6/j5WWpbf7qpOWmnZxVwuyL mfH1y2PD6YRanP3is3Os9G53IsZv05BflrucFT1E9qvLQGxXkyFV5RdXUiy4YyPArO Hhov+bhLb2DJnChEbxtHCbPTAOxyxB6VpgYoreychW8tx6pgy5cRipz4WExliAl3lJ +bTIJ7bYiOBbg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Youling Tang , Tony Lindgren , Sasha Levin , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 28/66] ARM: OMAP2+: Fix memleak in omap2xxx_clkt_vps_init Date: Tue, 22 Dec 2020 21:22:14 -0500 Message-Id: <20201223022253.2793452-28-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Youling Tang [ Upstream commit 3c5902d270edb6ccc3049acfe5d3e96653c87dcd ] If the clk_register fails, we should free hw before function returns to prevent memleak. Signed-off-by: Youling Tang Signed-off-by: Tony Lindgren Signed-off-by: Sasha Levin --- arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c index b64d717bfab6c..45fa2a87d5715 100644 --- a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c +++ b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c @@ -247,6 +247,12 @@ void omap2xxx_clkt_vps_init(void) hw->hw.init = &init; clk = clk_register(NULL, &hw->hw); + if (IS_ERR(clk)) { + printk(KERN_ERR "Failed to register clock\n"); + kfree(hw); + return; + } + clkdev_create(clk, "cpufreq_ck", NULL); return; cleanup: -- 2.27.0