Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3711879imu; Mon, 28 Jan 2019 09:27:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN5tTPyiNeLN/tX0CdPertfttgVxjGtMt96prUo2bw8nSuHRHQXl4/cvDN3Vkz2yD81Xtwci X-Received: by 2002:a62:9719:: with SMTP id n25mr23471267pfe.240.1548696444530; Mon, 28 Jan 2019 09:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696444; cv=none; d=google.com; s=arc-20160816; b=BZCXoAYBrxvn2Oz2b+oJbig0s7JLi/JtGCFM/htjUZj9B5pnZ3vz2lyNNCDrse8cTu 1B8OjjMjkZiWhXwDPBSHd1SRN70Te5xGO+gTEMWDf7lO+zaZXqjDvcb0fFnhxzTgl+jw VUPi4ulORZgcLW7u9BCNVywvy/hcNEuqVOokty60mcuY1WqNzBWiCofnJtqET3gPkTVj Dctcw7gIO5mq5t+ruqMNbMBrKbvn9x9W63e+fmstNehTFePTcAliBmzK/6z5Q+NMq7rO dO7fg0jnld7kxdFkOnzut+VwlpvjhYf07L/ownmrq79+P0voFE+4Oj8x5SYCiF1EO8du l1TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6+Jy0uTKLwoVSn2NC74qDSRrSijb2ZLE1El+6L/5d5I=; b=UEh94i/2roYe+LARUQcyCRjvxvK9iNQSU3p3TWNtUDxLXVJH+d/uNRryuKZLP7uNpx RsOAhNE1MZ01KbG0cBrjgJj4b4yfF8txhsF8v2hhNNPVMqjaIvKGu4+EBiy2DAhSEXXR nf52XpHZ1ND+oQQTzMi8VuHsQ9slw44D8UdfbgC3Cz1LLCJUdXNU4iwKO1Ye60WV8DPe WgommdekczewrFO9Km/C9ZYMawUHNC7hyWnmERJ5EycTzjI3ZrtFWE1huigq7CtATFgP un8M5ZsQ6mk+PpjZhBzK1RyaJj+OaM5/px/0F2tYq+jji2YnU0tcsQffVLzP2ZxHomMH 3dmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VFxv8uEJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 97si33953726plb.3.2019.01.28.09.27.08; Mon, 28 Jan 2019 09:27:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VFxv8uEJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730269AbfA1R1G (ORCPT + 99 others); Mon, 28 Jan 2019 12:27:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:45630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730764AbfA1QAW (ORCPT ); Mon, 28 Jan 2019 11:00:22 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2215A21852; Mon, 28 Jan 2019 16:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691222; bh=rA3BSpmdBaghDtwFln+RvjM8tmQS+Y238CqwlyoaXBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VFxv8uEJtvhNp3RwXMDB1YJnFb+2mDJXEPAKHt3Ewxkym440kDnOu3CmXN1W2hFyH jiYXQwZ2N2W1kLmUirE7DojMfnADUhzGq2mYPEmFM0aC5tbCwrLoMRtzht3GzmeKcv 4b56MfVh5B/j/Twc0fHV5A1MRG4+cLfLGDfkRVdc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yi Wang , Stephen Boyd , Sasha Levin , linux-mips@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 020/258] clk: boston: fix possible memory leak in clk_boston_setup() Date: Mon, 28 Jan 2019 10:55:26 -0500 Message-Id: <20190128155924.51521-20-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yi Wang [ Upstream commit 46fda5b5067a391912cf73bf3d32c26b6a22ad09 ] Smatch report warnings: drivers/clk/imgtec/clk-boston.c:76 clk_boston_setup() warn: possible memory leak of 'onecell' drivers/clk/imgtec/clk-boston.c:83 clk_boston_setup() warn: possible memory leak of 'onecell' drivers/clk/imgtec/clk-boston.c:90 clk_boston_setup() warn: possible memory leak of 'onecell' 'onecell' is malloced in clk_boston_setup(), but not be freed before leaving from the error handling cases. Signed-off-by: Yi Wang Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/imgtec/clk-boston.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/clk/imgtec/clk-boston.c b/drivers/clk/imgtec/clk-boston.c index 15af423cc0c9..f5d54a64d33c 100644 --- a/drivers/clk/imgtec/clk-boston.c +++ b/drivers/clk/imgtec/clk-boston.c @@ -73,27 +73,32 @@ static void __init clk_boston_setup(struct device_node *np) hw = clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq); if (IS_ERR(hw)) { pr_err("failed to register input clock: %ld\n", PTR_ERR(hw)); - return; + goto error; } onecell->hws[BOSTON_CLK_INPUT] = hw; hw = clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_freq); if (IS_ERR(hw)) { pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw)); - return; + goto error; } onecell->hws[BOSTON_CLK_SYS] = hw; hw = clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_freq); if (IS_ERR(hw)) { pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw)); - return; + goto error; } onecell->hws[BOSTON_CLK_CPU] = hw; err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell); if (err) pr_err("failed to add DT provider: %d\n", err); + + return; + +error: + kfree(onecell); } /* -- 2.19.1