Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp501902pxb; Wed, 3 Mar 2021 08:22:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKp0RwABy0+NnFgNYJ76NApp7cMCYh7NZC8oLi6xXXtTi8RqOjZ4afDpeHFjj7UAUCA1aU X-Received: by 2002:a17:906:c081:: with SMTP id f1mr26711047ejz.97.1614788555594; Wed, 03 Mar 2021 08:22:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614788555; cv=none; d=google.com; s=arc-20160816; b=feyKJIfRV7kWikiqB9XJLWpp6Y0UACpydDE2NF28JZA9x/VWeQFE4sXbcO2E0bQFen MWlFr5rg635iKQvEM/NaOra+BT5IZP7sz9c6w1MhN+NdPevAA2AuBYo09UbouLcCQ+dz oSkUNH13AsBn9CGYm8s2UYwIDSC+RzlSjBUKyCHllKH4WvnvROLC+aODU57THVkSObaJ ghj5NUXTji0pG022hzic+0lIm6J30R6EfamqqEtpSklmR3rvTnnrkxM1k9fzgrZfE4sf V4s9J7dkgZxuargAwiTeJSbVOMf62IStQAtt/NrcbF0xHyGUPSFkw8ua4avyjtwGi8Mu uzkA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5rTirfxYzAakAqL47VQ+2ucMCnj5cW3MStQS/aHjFFw=; b=j1SuaLGfLRL1tU4DbSFT7BJtRn6UJ46mYEvkJCaIYfbsIIzIdf9WZKM3l2cyRlNGRx VkW3t/mCB0OxnzRgZr4EI00YzgeChVUeIrrOrOhTRIppOalXBOEXXIkS2DbzAC/ymnri pIe4Dz1OJpJ98tRyHXPWEKBQXLwqOkm7H6eKxP1cNWZa8uX2J1BqFWVP9LP8terU9mr+ KYY9cWVo/sEZSEIePfcA2cKtNrzcWQaoOUe6pPSioHCbqXJkp258tTn7Ntc90G4f9yLQ 4UHKX8rycTtiJEH1HPoSBloxnfXCxF35S3DNNQu+xLUiqsIAJHqki0U2V15QicOFSpQe Kcxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vE/VDWv0"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq7si3341076ejc.300.2021.03.03.08.21.21; Wed, 03 Mar 2021 08:22:35 -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=@linuxfoundation.org header.s=korg header.b="vE/VDWv0"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346890AbhCAXvB (ORCPT + 99 others); Mon, 1 Mar 2021 18:51:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:34278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239320AbhCASOK (ORCPT ); Mon, 1 Mar 2021 13:14:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DA576508A; Mon, 1 Mar 2021 17:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619786; bh=2vyHBnX6YcabTICcKqGF/9Jh0f4R8QeEyCeAD/U3Uyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vE/VDWv0NoEq2m77Td4vOCanaOUpSY9MjNppWoiMTSIP9Y6gscTnoGBw8tacwH8VX taBGyQOm/qzjjoZk4a5FK4nmFY1Sv/asw4XZxlftBU7+rVjeTerI0vkSpqWRq100RQ t+xd8k+B/SZmJrVDhfrJWnO5iaCNueNe/rtgVdnA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, qiuguorui1 , Will Deacon Subject: [PATCH 5.10 580/663] arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails Date: Mon, 1 Mar 2021 17:13:48 +0100 Message-Id: <20210301161210.559104400@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: qiuguorui1 commit 656d1d58d8e0958d372db86c24f0b2ea36f50888 upstream. in function create_dtb(), if fdt_open_into() fails, we need to vfree buf before return. Fixes: 52b2a8af7436 ("arm64: kexec_file: load initrd and device-tree") Cc: stable@vger.kernel.org # v5.0 Signed-off-by: qiuguorui1 Link: https://lore.kernel.org/r/20210218125900.6810-1-qiuguorui1@huawei.com Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/machine_kexec_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -182,8 +182,10 @@ static int create_dtb(struct kimage *ima /* duplicate a device tree blob */ ret = fdt_open_into(initial_boot_params, buf, buf_size); - if (ret) + if (ret) { + vfree(buf); return -EINVAL; + } ret = setup_dtb(image, initrd_load_addr, initrd_len, cmdline, buf);