Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6270675imu; Mon, 21 Jan 2019 06:09:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN5hoM8O92z4e0Pt65ohZkkpugd5uszxCXTOS5cgDzHcRWr7bpWCOynkYzfB0Rs3AQRaWOGc X-Received: by 2002:a17:902:9887:: with SMTP id s7mr29603411plp.199.1548079777727; Mon, 21 Jan 2019 06:09:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079777; cv=none; d=google.com; s=arc-20160816; b=EtjpYBqZ4cqQ5vHIr7ccROewUD0Pau5w1G1kU8IaGGCa+pYj4oRP0EMwgE0ViR+h+k VdjIGNg3dmeG36scZ5b1o+L+M94Sm5FKSRVrssND/PhyT/D9hl/IFw3kWmE4ig7UlwBp 5MVRPG6FIz847jG2II60/XbPo8PxwakjYP0snsepuuhY8IDX+fOkNdu/2XfZLjKpWICF QoOYHxtV4FvsOdZ1ZJkc8/DfNR8AWYYuZBIn5dOSh6947jJvkVN+jdYrl0913GSLVYro trRAGY1NC3ipMUzLNN8NqHBm3n3uABGsGK06ZBnA62uEwVzFUFAudgOysaaQOdqwXDzU ZfpQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=efJr9uaTn5BxmE9EG7RRkPTzZRw32xqQo8Pbd9J07bc=; b=mZFM+1cMIGLJIcHb6CKtAP31l1o87Unjmk8mRuowuLyudEtfLHnmqydYptdVWOlwrO wqbviPxLpCWd4oShyXxc/xGJ2uv9Kxfd3u1Xt5IrlMqL7Bf5KaXVKv9nniHcobSP1KRv i/06fTDQMWHiXQa063x7gv7MeEGomuj1a15iNYt4Ztnz6hYK0099u5nMPx07hF7Scaq8 Vkr46Vy49nZgCBAW4JfnatnYgkFcZvnBTdgG96dzu9guzQM1mhifZ1IlhlDM3LZtILyo MXDyWo1JE8OrOZ6of3th4kgdJo5l7vNzc1bZtNCVFxVGcHcQAVmlxzXM1RvKNKod9MkQ +lNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BBmdgofa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z71si12795645pgd.490.2019.01.21.06.09.22; Mon, 21 Jan 2019 06:09:37 -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=BBmdgofa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730514AbfAUOGO (ORCPT + 99 others); Mon, 21 Jan 2019 09:06:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:47296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732446AbfAUOAi (ORCPT ); Mon, 21 Jan 2019 09:00:38 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A9762084C; Mon, 21 Jan 2019 14:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079237; bh=wHo3zoN7egvUHjiHU/hvBuDLBBi+4sI0GAgwo9ji/HE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBmdgofa4L2l69iftTIEuhsG9kMI1cLlH8H9SEoJ6AOrsJQBrNyoyeb+/ixHWeSH7 cUAskDvs4RRFiyTrPH45YKfdj6UGnJJdoVa2URDLtvZPkFkrs2zZspi3tnr1bMe+sV aDYpv5wptVzYgh94tIhkTOSTShy2780KD/59h9hk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yue Hu , Kees Cook Subject: [PATCH 4.19 56/99] pstore/ram: Avoid allocation and leak of platform data Date: Mon, 21 Jan 2019 14:48:48 +0100 Message-Id: <20190121134916.107440276@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit 5631e8576a3caf606cdc375f97425a67983b420c upstream. Yue Hu noticed that when parsing device tree the allocated platform data was never freed. Since it's not used beyond the function scope, this switches to using a stack variable instead. Reported-by: Yue Hu Fixes: 35da60941e44 ("pstore/ram: add Device Tree bindings") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- fs/pstore/ram.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -713,18 +713,15 @@ static int ramoops_probe(struct platform { struct device *dev = &pdev->dev; struct ramoops_platform_data *pdata = dev->platform_data; + struct ramoops_platform_data pdata_local; struct ramoops_context *cxt = &oops_cxt; size_t dump_mem_sz; phys_addr_t paddr; int err = -EINVAL; if (dev_of_node(dev) && !pdata) { - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) { - pr_err("cannot allocate platform data buffer\n"); - err = -ENOMEM; - goto fail_out; - } + pdata = &pdata_local; + memset(pdata, 0, sizeof(*pdata)); err = ramoops_parse_dt(pdev, pdata); if (err < 0)