Fix the potential NULL pointer dereference issue raised by Coverity.
578 reconn = malloc(sizeof(*reconn));
>>> CID 127481: Null pointer dereferences (NULL_RETURNS)
>>> Dereferencing a null pointer "reconn".
579 reconn->un = un;
Coverity issue: 127481
Fixes:
e623e0c6d8a5 ("vhost: add reconnect ability")
Reported-by: John McNamara <john.mcnamara@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
RTE_LOG(ERR, VHOST_CONFIG, "%s: reconnecting...\n", path);
reconn = malloc(sizeof(*reconn));
+ if (reconn == NULL) {
+ RTE_LOG(ERR, VHOST_CONFIG,
+ "failed to allocate memory for reconnect\n");
+ close(fd);
+ return -1;
+ }
reconn->un = un;
reconn->fd = fd;
reconn->vsocket = vsocket;