This issue reported by PVS studio, described as: https://pvs-studio.com/en/docs/warnings/v595/
Signed-off-by: Renyong Wan <wa...@yunsilicon.com> --- drivers/net/xsc/xsc_np.c | 2 +- drivers/net/xsc/xsc_rx.c | 2 +- drivers/net/xsc/xsc_vfio.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/xsc/xsc_np.c b/drivers/net/xsc/xsc_np.c index f032a0dbc2..eff7497255 100644 --- a/drivers/net/xsc/xsc_np.c +++ b/drivers/net/xsc/xsc_np.c @@ -172,13 +172,13 @@ xsc_dev_np_exec(struct xsc_dev *xdev, void *cmd, int len, int table, int opmod) out_len = sizeof(struct xsc_np_mbox_out) + data_len; cmd_len = RTE_MAX(in_len, out_len); in = malloc(cmd_len); - memset(in, 0, cmd_len); if (in == NULL) { rte_errno = ENOMEM; PMD_DRV_LOG(ERR, "Failed to alloc np cmd memory"); return -rte_errno; } + memset(in, 0, cmd_len); in->hdr.opcode = rte_cpu_to_be_16(XSC_CMD_OP_EXEC_NP); in->len = rte_cpu_to_be_16(data_len); diff --git a/drivers/net/xsc/xsc_rx.c b/drivers/net/xsc/xsc_rx.c index 140d7728d6..dfb71ed087 100644 --- a/drivers/net/xsc/xsc_rx.c +++ b/drivers/net/xsc/xsc_rx.c @@ -296,13 +296,13 @@ xsc_rss_qp_create(struct xsc_ethdev_priv *priv, int port_id) out_len = sizeof(struct xsc_cmd_create_multiqp_mbox_out) + entry_total_len; cmd_len = RTE_MAX(in_len, out_len); in = malloc(cmd_len); - memset(in, 0, cmd_len); if (in == NULL) { rte_errno = ENOMEM; PMD_DRV_LOG(ERR, "Alloc rss qp create cmd memory failed"); goto error; } + memset(in, 0, cmd_len); in->qp_num = rte_cpu_to_be_16((uint16_t)priv->num_rq); in->qp_type = XSC_QUEUE_TYPE_RAW; in->req_len = rte_cpu_to_be_32(cmd_len); diff --git a/drivers/net/xsc/xsc_vfio.c b/drivers/net/xsc/xsc_vfio.c index 6c679449af..2cd796ba26 100644 --- a/drivers/net/xsc/xsc_vfio.c +++ b/drivers/net/xsc/xsc_vfio.c @@ -431,13 +431,13 @@ xsc_vfio_rx_cq_create(struct xsc_dev *xdev, struct xsc_rx_cq_params *cq_params, } in = malloc(cmd_len); - memset(in, 0, cmd_len); if (in == NULL) { rte_errno = ENOMEM; PMD_DRV_LOG(ERR, "Failed to alloc rx cq exec cmd memory"); goto error; } + memset(in, 0, cmd_len); in->hdr.opcode = rte_cpu_to_be_16(XSC_CMD_OP_CREATE_CQ); in->ctx.eqn = 0; in->ctx.pa_num = rte_cpu_to_be_16(pa_num); -- 2.25.1