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/bus/dpaa/base/fman/fman.c | 8 ++++++--
drivers/bus/dpaa/dpaa_bus.c | 5 ++++-
2 files changed, 10 insertions(+), 3 deletions(-)
@@ -1132,6 +1132,7 @@ fman_init(void)
void
fman_finish(void)
{
+ char errmsg[RTE_STRERR_BUFSIZE];
struct __fman_if *__if, *tmpif;
assert(fman_ccsr_map_fd != -1);
@@ -1153,8 +1154,11 @@ fman_finish(void)
in_be32(__if->ccsr_map + 8) & ~(u32)3);
/* release the mapping */
_errno = munmap(__if->ccsr_map, __if->regs_size);
- if (unlikely(_errno < 0))
- FMAN_ERR(_errno, "munmap() = (%s)", strerror(errno));
+ if (unlikely(_errno < 0)) {
+ if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno);
+ FMAN_ERR(_errno, "munmap() = (%s)", errmsg);
+ }
DPAA_BUS_INFO("Tearing down %s", __if->node_path);
list_del(&__if->__if.node);
rte_free(__if);
@@ -627,12 +627,15 @@ rte_dpaa_bus_dev_build(void)
static int rte_dpaa_setup_intr(struct rte_intr_handle *intr_handle)
{
+ char errmsg[RTE_STRERR_BUFSIZE];
int fd;
fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
if (fd < 0) {
+ if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno);
DPAA_BUS_ERR("Cannot set up eventfd, error %i (%s)",
- errno, strerror(errno));
+ errno, errmsg);
return errno;
}