The function strerror() is insecure in a multi-thread environment.
This patch uses strerror_r() to replace it.
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
---
drivers/net/dpaa2/dpaa2_ethdev.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
@@ -1163,22 +1163,28 @@ dpaa2_eth_setup_irqs(struct rte_eth_dev *dev, int enable)
struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
int irq_index = DPNI_IRQ_INDEX;
unsigned int mask = DPNI_IRQ_EVENT_LINK_CHANGED;
+ char errmsg[RTE_STRERR_BUFSIZE];
PMD_INIT_FUNC_TRACE();
err = dpni_set_irq_mask(dpni, CMD_PRI_LOW, priv->token,
irq_index, mask);
if (err < 0) {
+ if (strerror_r(-err, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -err);
DPAA2_PMD_ERR("Error: dpni_set_irq_mask():%d (%s)", err,
- strerror(-err));
+ errmsg);
return err;
}
err = dpni_set_irq_enable(dpni, CMD_PRI_LOW, priv->token,
irq_index, enable);
- if (err < 0)
+ if (err < 0) {
+ if (strerror_r(-err, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -err);
DPAA2_PMD_ERR("Error: dpni_set_irq_enable():%d (%s)", err,
- strerror(-err));
+ errmsg);
+ }
return err;
}