[PATCH net-next v2 1/4] net: marvell: prestera: do not fail if FW reply is bigger

From: Vadym Kochan
Date: Mon Aug 02 2021 - 10:16:13 EST


From: Vadym Kochan <vkochan@xxxxxxxxxxx>

There might be a case when driver talks to the newer FW version
which has extended message packets with extra fields, in that case
lets just copy minimum what we need/can.

Signed-off-by: Vadym Kochan <vkochan@xxxxxxxxxxx>
---
drivers/net/ethernet/marvell/prestera/prestera_pci.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
index a250d394da38..58642b540322 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
@@ -359,12 +359,7 @@ static int prestera_fw_cmd_send(struct prestera_fw *fw,
}

ret_size = prestera_fw_read(fw, PRESTERA_CMD_RCV_LEN_REG);
- if (ret_size > out_size) {
- dev_err(fw->dev.dev, "ret_size (%u) > out_len(%zu)\n",
- ret_size, out_size);
- err = -EMSGSIZE;
- goto cmd_exit;
- }
+ ret_size = min_t(u32, ret_size, out_size);

memcpy_fromio(out_msg, fw->cmd_mbox + in_size, ret_size);

--
2.17.1