From: Philipp Rudo <prudo@redhat.com>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: Mukesh Pilaniya <mpilaniy@redhat.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Morton <akpm@linux-foundation.org>,
Baoquan He <baoquan.he@linux.dev>,
Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Tao Liu <ltao@redhat.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
linux-riscv@lists.infradead.org, kexec@lists.infradead.org
Subject: Re: [PATCH v2 2/2] kexec: fix error propagation in kexec_image_probe_default()
Date: Fri, 21 Aug 2026 10:40:26 +0200 [thread overview]
Message-ID: <20260821104026.07b7a31d@rotkaeppchen> (raw)
In-Reply-To: <2vxzik54zmpp.fsf@kernel.org>
Hi Pratyush,
On Thu, 20 Aug 2026 20:11:14 +0200
Pratyush Yadav <pratyush@kernel.org> wrote:
> On Thu, Aug 20 2026, Philipp Rudo wrote:
>
> > Hi Mukesh,
> > Hi Pratyush,
> >
> > having this patch makes sense. Personally I'd go with having a
> > switch-case rather than individual if-blocks. E.g.
> >
> > switch (ret) {
> > case 0:
> > image->fops = *fops;
> > return 0;
> > case -ENOEXEC:
> > continue;
> > default:
> > return ret;
> > }
> >
> > IMHO that is better readable and easier to extend in case other error
> > codes need special handling as well. But that is only my personal
> > opinion.
>
> Well, IMO both look roughly the same so I unless Mukesh prefers your
> version more, we can keep it as-is.
that's why I've marked it as a personal preference. I don't expect
Mukesh to switch to it. Still I thought it is worth mentioning just to
give an other perspective.
> >
> > Independent on which implementation you use.
> >
> > Reviewed-by: Philipp Rudo <prudo@redhat.com>
>
> Thanks for reviewing!
>
> One tiny suggestion. Can you please reply in-line the next time around?
> It is a bit easier reading this response below the code that it refers
> to.
Agree, especially with larger, more complex patches. In this case
however, I thought that the patch is so small that it wouldn't make
much of a difference.
Anyway, I'll reply in-line next time in such cases as well.
Thanks for your review!
Philipp
> >
> >
> > On Wed, 19 Aug 2026 23:17:23 +0530
> > Mukesh Pilaniya <mpilaniy@redhat.com> wrote:
> >
> >> kexec_image_probe_default() overwrites ret with each loader's probe
> >> return value and returns whatever the last loader returned when no
> >> probe matches. The error code reaching userspace depends on whichever
> >> loader happens to be last in kexec_file_loaders[].
> >>
> >> Only continue to the next loader when a probe returns -ENOEXEC.
> >> Propagate any other error such as -ENOMEM immediately. Return -ENOEXEC
> >> only when all loaders have been tried and none matched.
> >>
> >> Suggested-by: Pratyush Yadav <pratyush@kernel.org>
> >> Signed-off-by: Mukesh Pilaniya <mpilaniy@redhat.com>
> >> ---
> >> kernel/kexec_file.c | 12 +++++++-----
> >> 1 file changed, 7 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> >> index 59fb9d71e9d8..b3060e984ef3 100644
> >> --- a/kernel/kexec_file.c
> >> +++ b/kernel/kexec_file.c
> >> @@ -68,17 +68,19 @@ int kexec_image_probe_default(struct kimage *image, void *buf,
> >> unsigned long buf_len)
> >> {
> >> const struct kexec_file_ops * const *fops;
> >> - int ret = -ENOEXEC;
> >>
> >> for (fops = &kexec_file_loaders[0]; *fops && (*fops)->probe; ++fops) {
> >> - ret = (*fops)->probe(buf, buf_len);
> >> - if (!ret) {
> >> + int ret = (*fops)->probe(buf, buf_len);
> >> +
> >> + if (ret == 0) {
> >> image->fops = *fops;
> >> - return ret;
> >> + return 0;
> >> }
> >> + if (ret != -ENOEXEC)
> >> + return ret;
> >> }
> >>
> >> - return ret;
> >> + return -ENOEXEC;
> >> }
> >>
> >> static void *kexec_image_load_default(struct kimage *image)
> >>
> >
>
WARNING: multiple messages have this Message-ID (diff)
From: Philipp Rudo <prudo@redhat.com>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: Mukesh Pilaniya <mpilaniy@redhat.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Morton <akpm@linux-foundation.org>,
Baoquan He <baoquan.he@linux.dev>,
Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Tao Liu <ltao@redhat.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
linux-riscv@lists.infradead.org, kexec@lists.infradead.org
Subject: Re: [PATCH v2 2/2] kexec: fix error propagation in kexec_image_probe_default()
Date: Fri, 21 Aug 2026 10:40:26 +0200 [thread overview]
Message-ID: <20260821104026.07b7a31d@rotkaeppchen> (raw)
In-Reply-To: <2vxzik54zmpp.fsf@kernel.org>
Hi Pratyush,
On Thu, 20 Aug 2026 20:11:14 +0200
Pratyush Yadav <pratyush@kernel.org> wrote:
> On Thu, Aug 20 2026, Philipp Rudo wrote:
>
> > Hi Mukesh,
> > Hi Pratyush,
> >
> > having this patch makes sense. Personally I'd go with having a
> > switch-case rather than individual if-blocks. E.g.
> >
> > switch (ret) {
> > case 0:
> > image->fops = *fops;
> > return 0;
> > case -ENOEXEC:
> > continue;
> > default:
> > return ret;
> > }
> >
> > IMHO that is better readable and easier to extend in case other error
> > codes need special handling as well. But that is only my personal
> > opinion.
>
> Well, IMO both look roughly the same so I unless Mukesh prefers your
> version more, we can keep it as-is.
that's why I've marked it as a personal preference. I don't expect
Mukesh to switch to it. Still I thought it is worth mentioning just to
give an other perspective.
> >
> > Independent on which implementation you use.
> >
> > Reviewed-by: Philipp Rudo <prudo@redhat.com>
>
> Thanks for reviewing!
>
> One tiny suggestion. Can you please reply in-line the next time around?
> It is a bit easier reading this response below the code that it refers
> to.
Agree, especially with larger, more complex patches. In this case
however, I thought that the patch is so small that it wouldn't make
much of a difference.
Anyway, I'll reply in-line next time in such cases as well.
Thanks for your review!
Philipp
> >
> >
> > On Wed, 19 Aug 2026 23:17:23 +0530
> > Mukesh Pilaniya <mpilaniy@redhat.com> wrote:
> >
> >> kexec_image_probe_default() overwrites ret with each loader's probe
> >> return value and returns whatever the last loader returned when no
> >> probe matches. The error code reaching userspace depends on whichever
> >> loader happens to be last in kexec_file_loaders[].
> >>
> >> Only continue to the next loader when a probe returns -ENOEXEC.
> >> Propagate any other error such as -ENOMEM immediately. Return -ENOEXEC
> >> only when all loaders have been tried and none matched.
> >>
> >> Suggested-by: Pratyush Yadav <pratyush@kernel.org>
> >> Signed-off-by: Mukesh Pilaniya <mpilaniy@redhat.com>
> >> ---
> >> kernel/kexec_file.c | 12 +++++++-----
> >> 1 file changed, 7 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> >> index 59fb9d71e9d8..b3060e984ef3 100644
> >> --- a/kernel/kexec_file.c
> >> +++ b/kernel/kexec_file.c
> >> @@ -68,17 +68,19 @@ int kexec_image_probe_default(struct kimage *image, void *buf,
> >> unsigned long buf_len)
> >> {
> >> const struct kexec_file_ops * const *fops;
> >> - int ret = -ENOEXEC;
> >>
> >> for (fops = &kexec_file_loaders[0]; *fops && (*fops)->probe; ++fops) {
> >> - ret = (*fops)->probe(buf, buf_len);
> >> - if (!ret) {
> >> + int ret = (*fops)->probe(buf, buf_len);
> >> +
> >> + if (ret == 0) {
> >> image->fops = *fops;
> >> - return ret;
> >> + return 0;
> >> }
> >> + if (ret != -ENOEXEC)
> >> + return ret;
> >> }
> >>
> >> - return ret;
> >> + return -ENOEXEC;
> >> }
> >>
> >> static void *kexec_image_load_default(struct kimage *image)
> >>
> >
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-08-21 8:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 17:47 [PATCH v2 0/2] kexec: fix probe error codes and error propagation Mukesh Pilaniya
2026-08-19 17:47 ` Mukesh Pilaniya
2026-08-19 17:47 ` [PATCH v2 1/2] kexec: return -ENOEXEC from image probe functions on mismatch Mukesh Pilaniya
2026-08-19 17:47 ` Mukesh Pilaniya
2026-08-19 18:33 ` Bradley Morgan
2026-08-19 18:33 ` Bradley Morgan
2026-08-19 17:47 ` [PATCH v2 2/2] kexec: fix error propagation in kexec_image_probe_default() Mukesh Pilaniya
2026-08-19 17:47 ` Mukesh Pilaniya
2026-08-20 12:21 ` Philipp Rudo
2026-08-20 12:21 ` Philipp Rudo
2026-08-20 18:11 ` Pratyush Yadav
2026-08-20 18:11 ` Pratyush Yadav
2026-08-21 7:18 ` Mukesh Pilaniya
2026-08-21 7:18 ` Mukesh Pilaniya
2026-08-21 8:08 ` Mike Rapoport
2026-08-21 8:08 ` Mike Rapoport
2026-08-21 13:22 ` Mukesh Pilaniya
2026-08-21 13:22 ` Mukesh Pilaniya
2026-08-21 8:40 ` Philipp Rudo [this message]
2026-08-21 8:40 ` Philipp Rudo
2026-08-20 18:08 ` Pratyush Yadav
2026-08-20 18:08 ` Pratyush Yadav
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=20260821104026.07b7a31d@rotkaeppchen \
--to=prudo@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=baoquan.he@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=loongarch@lists.linux.dev \
--cc=ltao@redhat.com \
--cc=mark.rutland@arm.com \
--cc=mpilaniy@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pasha.tatashin@soleen.com \
--cc=pjw@kernel.org \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=will@kernel.org \
/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.