From: Lee Jones <lee@kernel.org>
To: "Thomas Richard (congatec GmbH)" <thomas.richard@bootlin.com>
Cc: Andi Shyti <andi.shyti@kernel.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Werner Gartner <Werner.Gartner@congatec.com>,
mfd@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-i2c@vger.kernel.org, stable@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle
Date: Wed, 2 Sep 2026 16:02:06 +0100 [thread overview]
Message-ID: <20260902150206.GB2082450@google.com> (raw)
In-Reply-To: <20260811-cgbc-i2c-storage-devices-support-v2-1-3efa998e0ef5@bootlin.com>
On Tue, 11 Aug 2026, Thomas Richard (congatec GmbH) wrote:
> The cgbc_session_command() return value was directly cast to u8 and used
> as session handle without error checking. Casting a negative error to u8
> produces a valid-looking session handle. So check if return value is
> positive before to cast and use it.
>
> Cc: stable@vger.kernel.org
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260713-cgbc-core-fix-cgbc-remove-v1-1-79274ad62b3a%40bootlin.com?part=1
> Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver")
> Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
> ---
> drivers/mfd/cgbc-core.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
> index 2becaf797646..4a409234e66c 100644
> --- a/drivers/mfd/cgbc-core.c
> +++ b/drivers/mfd/cgbc-core.c
> @@ -103,7 +103,11 @@ static int cgbc_session_request(struct cgbc_device_data *cgbc)
> if (ret)
> return dev_err_probe(cgbc->dev, ret, "device not found or not ready\n");
>
> - cgbc->session = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
> + ret = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
> + if (ret < 0)
> + return dev_err_probe(cgbc->dev, ret, "session handle request timed out\n");
Can we make this a bit more user friendly?
"Failed to start XYZ session"?
> +
> + cgbc->session = ret;
>
> /* The Board Controller sent us a wrong session handle, we cannot communicate with it */
> if (cgbc->session < CGBC_SESSION_VALID_MIN || cgbc->session > CGBC_SESSION_VALID_MAX)
>
> --
> 2.53.0
>
--
Lee Jones
next prev parent reply other threads:[~2026-09-02 15:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 16:15 [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
2026-08-11 16:15 ` [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
2026-09-02 15:02 ` Lee Jones [this message]
2026-09-02 15:03 ` Lee Jones
2026-08-11 16:15 ` [PATCH v2 2/5] mfd: cgbc: Make cgbc_devs const Thomas Richard (congatec GmbH)
2026-08-11 16:15 ` [PATCH v2 3/5] i2c: cgbc: Add virtual I2C bus support Thomas Richard (congatec GmbH)
2026-08-11 16:15 ` [PATCH v2 4/5] mfd: " Thomas Richard (congatec GmbH)
2026-08-11 16:15 ` [PATCH v2 5/5] i2c: cgbc: Add virtual storage devices on the virtual I2C bus Thomas Richard (congatec GmbH)
2026-08-13 17:20 ` [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard
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=20260902150206.GB2082450@google.com \
--to=lee@kernel.org \
--cc=Werner.Gartner@congatec.com \
--cc=andi.shyti@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=thomas.richard@bootlin.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;
as well as URLs for NNTP newsgroup(s).