Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ben Levinsky" <ben.levinsky@amd.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org,
	wsa+renesas@sang-engineering.com
Subject: Re: [PATCH 3/4] remoteproc: add helper for optional ELF resource tables
Date: Wed, 13 May 2026 01:42:27 +0000	[thread overview]
Message-ID: <20260513014228.4B51BC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511211841.284809-4-ben.levinsky@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The helper rproc_elf_load_rsc_table_optional() silently ignores firmware corruption errors by incorrectly assuming all -EINVAL returns mean a missing table.
--

commit 0067d38d8bcda280b1137f92af4ffd133bfa24fe
Author: Ben Levinsky <ben.levinsky@amd.com>
remoteproc: add helper for optional ELF resource tables

This commit adds a wrapper around rproc_elf_load_rsc_table() to treat a
missing ELF resource table as optional. It does this by converting an
-EINVAL return code into a success code.

> diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
> --- a/drivers/remoteproc/remoteproc_internal.h
> +++ b/drivers/remoteproc/remoteproc_internal.h
[ ... ]
> @@ -146,6 +146,18 @@ static inline int rproc_mem_entry_iounmap(struct rproc *rproc,
>  	return 0;
>  }
>  
> +static inline int rproc_elf_load_rsc_table_optional(struct rproc *rproc,
> +						    const struct firmware *fw)
> +{
> +	int ret;
> +
> +	ret = rproc_elf_load_rsc_table(rproc, fw);
> +	if (ret == -EINVAL)
> +		dev_dbg(&rproc->dev, "no resource table found\n");
> +
> +	return ret == -EINVAL ? 0 : ret;

Does this inadvertently mask actual firmware corruption?

Looking at rproc_elf_load_rsc_table(), it returns -EINVAL when find_table()
fails:

drivers/remoteproc/remoteproc_elf_loader.c:rproc_elf_load_rsc_table() {
	...
	shdr = find_table(dev, fw);
	if (!shdr)
		return -EINVAL;
	...
}

However, find_table() returns NULL not only when the .resource_table section
is missing, but also when it is explicitly malformed (e.g., truncated,
missing header, unsupported version, or non-zero reserved bytes).

Since this helper converts all -EINVAL returns to success, will it allow
driver initialization to proceed with an invalid or corrupted resource table?

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260511211841.284809-1-ben.levinsky@amd.com?part=3

  parent reply	other threads:[~2026-05-13  1:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 21:18 [PATCH 0/4] remoteproc: cleanup shared carveout and resource-table helpers Ben Levinsky
2026-05-11 21:18 ` [PATCH 1/4] remoteproc: add common wc-ioremap carveout callbacks Ben Levinsky
2026-05-12  9:44   ` Arnaud POULIQUEN
     [not found]     ` <DM4PR12MB64482037D67096393D4668CE83392@DM4PR12MB6448.namprd12.prod.outlook.com>
2026-05-12 17:15       ` Ben Levinsky
2026-05-11 21:18 ` [PATCH 2/4] remoteproc: switch exact-match drivers to wc-ioremap callbacks Ben Levinsky
2026-05-12  7:06   ` Geert Uytterhoeven
2026-05-13  1:33   ` sashiko-bot
2026-05-11 21:18 ` [PATCH 3/4] remoteproc: add helper for optional ELF resource tables Ben Levinsky
2026-05-12  7:55   ` Daniel Baluta
2026-05-12  9:22     ` Arnaud POULIQUEN
2026-05-12 14:53     ` Shah, Tanmay
     [not found]       ` <DM4PR12MB6448B1E51D58F3F8B11171F683392@DM4PR12MB6448.namprd12.prod.outlook.com>
2026-05-12 17:19         ` Ben Levinsky
2026-05-13  6:30       ` Daniel Baluta
2026-05-13  7:37         ` Arnaud POULIQUEN
2026-05-13  1:42   ` sashiko-bot [this message]
2026-05-11 21:18 ` [PATCH 4/4] remoteproc: switch drivers to optional resource-table helper Ben Levinsky
2026-05-12  7:07   ` Geert Uytterhoeven
2026-05-13  2:48   ` sashiko-bot

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=20260513014228.4B51BC2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=ben.levinsky@amd.com \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox