All of lore.kernel.org
 help / color / mirror / Atom feed
From: qiuguorui1 <qiuguorui1@huawei.com>
To: <takahiro.akashi@linaro.org>, <catalin.marinas@arm.com>,
	<will@kernel.org>, <l.stelmach@samsung.com>, <lkml@SDF.ORG>,
	<akpm@linux-foundation.org>, <bgwin@google.com>,
	<rppt@kernel.org>, <gustavoars@kernel.org>, <tao.li@vivo.com>,
	<james.morse@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <zengweilin@huawei.com>,
	<liuwenliang@huawei.com>, <qiuguorui1@huawei.com>
Subject: [PATCH] arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails
Date: Thu, 18 Feb 2021 20:59:00 +0800	[thread overview]
Message-ID: <20210218125900.6810-1-qiuguorui1@huawei.com> (raw)

in function create_dtb(), if fdt_open_into() fails, we need to vfree
buf before return.

Fixes: 52b2a8af74360 ("arm64: kexec_file: load initrd and device-tree")
Cc: stable@vger.kernel.org # v5.0
Signed-off-by: qiuguorui1 <qiuguorui1@huawei.com>
---
 arch/arm64/kernel/machine_kexec_file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 03210f644790..0cde47a63beb 100644
--- 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 *image,
 
 		/* 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);
-- 
2.12.3


WARNING: multiple messages have this Message-ID (diff)
From: qiuguorui1 <qiuguorui1@huawei.com>
To: <takahiro.akashi@linaro.org>, <catalin.marinas@arm.com>,
	<will@kernel.org>, <l.stelmach@samsung.com>, <lkml@SDF.ORG>,
	<akpm@linux-foundation.org>, <bgwin@google.com>,
	<rppt@kernel.org>, <gustavoars@kernel.org>, <tao.li@vivo.com>,
	<james.morse@arm.com>
Cc: liuwenliang@huawei.com, qiuguorui1@huawei.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, zengweilin@huawei.com
Subject: [PATCH] arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails
Date: Thu, 18 Feb 2021 20:59:00 +0800	[thread overview]
Message-ID: <20210218125900.6810-1-qiuguorui1@huawei.com> (raw)

in function create_dtb(), if fdt_open_into() fails, we need to vfree
buf before return.

Fixes: 52b2a8af74360 ("arm64: kexec_file: load initrd and device-tree")
Cc: stable@vger.kernel.org # v5.0
Signed-off-by: qiuguorui1 <qiuguorui1@huawei.com>
---
 arch/arm64/kernel/machine_kexec_file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 03210f644790..0cde47a63beb 100644
--- 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 *image,
 
 		/* 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);
-- 
2.12.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2021-02-18 15:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-18 12:59 qiuguorui1 [this message]
2021-02-18 12:59 ` [PATCH] arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails qiuguorui1
2021-02-19 19:16 ` Will Deacon
2021-02-19 19:16   ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210218125900.6810-1-qiuguorui1@huawei.com \
    --to=qiuguorui1@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=bgwin@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=gustavoars@kernel.org \
    --cc=james.morse@arm.com \
    --cc=l.stelmach@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuwenliang@huawei.com \
    --cc=lkml@SDF.ORG \
    --cc=rppt@kernel.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=tao.li@vivo.com \
    --cc=will@kernel.org \
    --cc=zengweilin@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.