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