From: Ivan Vecera <ivecera@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Prathosh Satish <Prathosh.Satish@microchip.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Michal Schmidt <mschmidt@redhat.com>,
Petr Oros <poros@redhat.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>
Subject: Re: [PATCH net-next v3 3/5] dpll: zl3073x: Add firmware loading functionality
Date: Fri, 29 Aug 2025 12:39:30 +0200 [thread overview]
Message-ID: <94247dbc-4be8-4464-ad3e-5b81bba5f70b@redhat.com> (raw)
In-Reply-To: <20250818192203.364c73b1@kernel.org>
Hi Kuba,
sorry for the late response... (I was on PTO last 2 weeks).
On 19. 08. 25 4:22 dop., Jakub Kicinski wrote:
> On Wed, 13 Aug 2025 19:44:06 +0200 Ivan Vecera wrote:
>> +#define ZL3073X_FW_ERR_MSG(_zldev, _extack, _msg, ...) \
>> + do { \
>> + dev_err((_zldev)->dev, ZL3073X_FW_ERR_PFX _msg "\n", \
>> + ## __VA_ARGS__); \
>> + NL_SET_ERR_MSG_FMT_MOD((_extack), \
>> + ZL3073X_FW_ERR_PFX _msg, \
>> + ## __VA_ARGS__); \
>> + } while (0)
>
> Please don't duplicate the messages to the logs.
> If devlink error reporting doesn't work it needs to be fixed
> in the core.
OK, will fix this.
>> +static ssize_t
>> +zl3073x_fw_component_load(struct zl3073x_dev *zldev,
>> + struct zl3073x_fw_component **pcomp,
>> + const char **psrc, size_t *psize,
>> + struct netlink_ext_ack *extack)
>> +{
>> + const struct zl3073x_fw_component_info *info;
>> + struct zl3073x_fw_component *comp = NULL;
>> + struct device *dev = zldev->dev;
>> + enum zl3073x_fw_component_id id;
>> + char buf[32], name[16];
>> + u32 count, size, *dest;
>> + int pos, rc;
>> +
>> + /* Fetch image name and size from input */
>> + strscpy(buf, *psrc, min(sizeof(buf), *psize));
>> + rc = sscanf(buf, "%15s %u %n", name, &count, &pos);
>> + if (!rc) {
>> + /* No more data */
>> + return 0;
>> + } else if (rc == 1) {
>> + ZL3073X_FW_ERR_MSG(zldev, extack, "invalid component size");
>> + return -EINVAL;
>> + }
>> + *psrc += pos;
>> + *psize -= pos;
>
> what if pos > *psize ? I think the parsing needs more care.
This should not happen. strscpy copies min(32, *psize) from the source
to buf and sscanf parses buf and fills pos by index from the buf.
The pos cannot be greater than *psize...or did I miss something?
Thanks,
Ivan
next prev parent reply other threads:[~2025-08-29 10:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 17:44 [PATCH net-next v3 0/5] dpll: zl3073x: Add support for devlink flash Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 1/5] dpll: zl3073x: Add functions to access hardware registers Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 2/5] dpll: zl3073x: Add low-level flash functions Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 3/5] dpll: zl3073x: Add firmware loading functionality Ivan Vecera
2025-08-19 2:22 ` Jakub Kicinski
2025-08-29 10:39 ` Ivan Vecera [this message]
2025-08-29 23:52 ` Jakub Kicinski
2025-08-20 6:40 ` Dan Carpenter
2025-08-29 10:31 ` Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 4/5] dpll: zl3073x: Refactor DPLL initialization Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 5/5] dpll: zl3073x: Implement devlink flash callback Ivan Vecera
2025-08-19 2:29 ` Jakub Kicinski
2025-08-29 14:49 ` Ivan Vecera
2025-08-29 23:56 ` Jakub Kicinski
2025-09-01 16:34 ` Ivan Vecera
2025-09-01 17:05 ` Jakub Kicinski
2025-08-14 9:30 ` [PATCH net-next v3 0/5] dpll: zl3073x: Add support for devlink flash Przemek Kitszel
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=94247dbc-4be8-4464-ad3e-5b81bba5f70b@redhat.com \
--to=ivecera@redhat.com \
--cc=Prathosh.Satish@microchip.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.kitszel@intel.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).