From nobody Mon Jun 8 05:24:59 2026 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05E5A3D4134 for ; Tue, 2 Jun 2026 22:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440556; cv=none; b=DcRfNIovFtovuPynM8TFSqUGX5Q0AtTROoLn9rpkvVnZcqprgTgUTByelrvn0qXtdPHjWwsYqSTzpCxffXALGIuTSGfM4nRlbnLtA/4SDffTkELRmPEHb0+Gl36YafvdhBRzHRg4rXJ5d12ujl2BnRNYknSOaLRpPbQeuSUdGos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440556; c=relaxed/simple; bh=tH5WJ66QRToRkxKMi5CzlJ8nS5W/lCMqd4UDM9GQwkU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kkrCWt8NQP0Je6nrQb8VWO3OB7t8ldFlHIXbNb8/KchJZ2Z2F+Wzkvqa0WK+Sm7DgBRni54SiAi3xH5JEyPJv8J6iNWAVrvW4HbfAHQX6qcDQustUGVrQJcdFMSJDlHfvEWX6NotaD/pOwv1ZKtbZSeKvOzYJ+sLYjoiEEPVa+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MTZHuGG1; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MTZHuGG1" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780440550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xTOuacRFqf7jRiO8aj4MgPqi+i+IVWIh9egGsHuyaHw=; b=MTZHuGG16xFHjwh8YRObibc+qHri/oFeWwccfRwxatMgxCdI1sfe5Yg7zte9PSgvNZHNAC l/hhMlpfVGOOqNxrlB192BaKaR85P4Dy/yvxegls7Hfh5I44juISra3CRgBr6jezQoTt1P XoMhraNz9u5nEGHDMw2i2hDNOklzl0k= From: Thorsten Blum To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Breno Leitao , Andrew Morton , Pasha Tatashin , Alexander Graf , Baoquan He , Song Shuai Cc: Thorsten Blum , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load Date: Wed, 3 Jun 2026 00:47:22 +0200 Message-ID: <20260602224725.1088385-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1420; i=thorsten.blum@linux.dev; h=from:subject; bh=tH5WJ66QRToRkxKMi5CzlJ8nS5W/lCMqd4UDM9GQwkU=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFnysbX62efmu2TG/wxgcXQQPfLKY67qGmGj+t8KR/QnH JabmRbRUcrCIMbFICumyPJg1o8ZvqU1lZtMInbCzGFlAhnCwMUpABOpiWRkaPa3Tt+0bBHjkSW/ 2yZHzJ78fsmFw5bFnzfd4a8/se3gk7OMDBOPpvjVyHtvULD1LmtNaHzBZ6O0fkMtf+G2Mq0TrFN 3MwEA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Use min() to replace the open-coded version and assign the result directly to kbuf.bufsz. Drop the now-unused local size variable. Signed-off-by: Thorsten Blum Reviewed-by: Breno Leitao --- arch/riscv/kernel/kexec_elf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/riscv/kernel/kexec_elf.c b/arch/riscv/kernel/kexec_elf.c index 531d348db84d..528141df90ba 100644 --- a/arch/riscv/kernel/kexec_elf.c +++ b/arch/riscv/kernel/kexec_elf.c @@ -19,6 +19,7 @@ #include #include #include +#include #include =20 static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, @@ -27,7 +28,6 @@ static int riscv_kexec_elf_load(struct kimage *image, str= uct elfhdr *ehdr, { int i; int ret =3D 0; - size_t size; struct kexec_buf kbuf =3D {}; const struct elf_phdr *phdr; =20 @@ -38,12 +38,8 @@ static int riscv_kexec_elf_load(struct kimage *image, st= ruct elfhdr *ehdr, if (phdr->p_type !=3D PT_LOAD) continue; =20 - size =3D phdr->p_filesz; - if (size > phdr->p_memsz) - size =3D phdr->p_memsz; - kbuf.buffer =3D (void *) elf_info->buffer + phdr->p_offset; - kbuf.bufsz =3D size; + kbuf.bufsz =3D min(phdr->p_filesz, phdr->p_memsz); kbuf.buf_align =3D phdr->p_align; kbuf.mem =3D phdr->p_paddr - old_pbase + new_pbase; kbuf.memsz =3D phdr->p_memsz;