[net,1/2] liquidio: Fix an off by one in octeon_download_firmware()
Commit Message
In order to append the 'boottime' string to 'h->bootcmd', the final NULL
has to betaken into account when checking if there is enough space.
Fixes: 907aaa6babe1 ("liquidio: pass date and time info to NIC firmware")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/ethernet/cavium/liquidio/octeon_console.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -899,13 +899,13 @@ int octeon_download_firmware(struct octeon_device *oct, const u8 *data,
ret = snprintf(boottime, MAX_BOOTTIME_SIZE,
" time_sec=%lld time_nsec=%ld",
(s64)ts.tv_sec, ts.tv_nsec);
- if ((sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd))) <
+ if ((sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd))) <=
ret) {
dev_err(&oct->pci_dev->dev, "Boot command buffer too small\n");
return -EINVAL;
}
strncat(h->bootcmd, boottime,
- sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd)));
+ sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd)) - 1);
dev_info(&oct->pci_dev->dev, "Writing boot command: %s\n",
h->bootcmd);