diff --git a/lib/ff_config.c b/lib/ff_config.c index a6b85eb58..1941c506a 100644 --- a/lib/ff_config.c +++ b/lib/ff_config.c @@ -114,7 +114,7 @@ parse_lcore_mask(struct ff_config *cfg, const char *coremask) if ((1 << j) & val) { proc_lcore[count] = idx; if (cfg->dpdk.proc_id == count) { - zero_num = idx >> 2; + zero_num = idx >> 2; shift = idx & 0x3; memset(zero,'0',zero_num); sprintf(buf, "%llx%s", (unsigned long long)1<buf_addr; + original_buf_len = msg->buf_len; msg->buf_addr = extra_buf; msg->buf_len = total_len; } @@ -71,9 +73,9 @@ sysctl(int *name, unsigned namelen, void *old, msg->msg_type = FF_SYSCTL; msg->sysctl.name = (int *)buf_addr; msg->sysctl.namelen = namelen; - memcpy(msg->sysctl.name, name, namelen*sizeof(int)); + memcpy(msg->sysctl.name, name, namelen * sizeof(int)); - buf_addr += namelen*sizeof(int); + buf_addr += namelen * sizeof(int); if (new != NULL && newlen != 0) { msg->sysctl.new = buf_addr; @@ -106,11 +108,7 @@ sysctl(int *name, unsigned namelen, void *old, int ret = ff_ipc_send(msg); if (ret < 0) { errno = EPIPE; - ff_ipc_msg_free(msg); - if (extra_buf) { - rte_free(extra_buf); - } - return -1; + goto error; } do { @@ -120,11 +118,7 @@ sysctl(int *name, unsigned namelen, void *old, ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; - ff_ipc_msg_free(msg); - if (extra_buf) { - rte_free(extra_buf); - } - return -1; + goto error; } } while (msg != retmsg); @@ -142,6 +136,11 @@ sysctl(int *name, unsigned namelen, void *old, errno = retmsg->result; } +error: + if (original_buf) { + msg->buf_addr = original_buf; + msg->buf_len = original_buf_len; + } ff_ipc_msg_free(msg); if (extra_buf) { rte_free(extra_buf);