Commit d61c9c81 authored by Dan Carpenter's avatar Dan Carpenter Committed by Kleber Sacilotto de Souza

misc: mic: SCIF Fix scif_get_new_port() error handling

BugLink: https://bugs.launchpad.net/bugs/1798539

[ Upstream commit a39284ae ]

There are only 2 callers of scif_get_new_port() and both appear to get
the error handling wrong.  Both treat zero returns as error, but it
actually returns negative error codes and >= 0 on success.

Fixes: e9089f43 ("misc: mic: SCIF open close bind and listen APIs")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 89cb901d
......@@ -370,11 +370,10 @@ int scif_bind(scif_epd_t epd, u16 pn)
goto scif_bind_exit;
}
} else {
pn = scif_get_new_port();
if (!pn) {
ret = -ENOSPC;
ret = scif_get_new_port();
if (ret < 0)
goto scif_bind_exit;
}
pn = ret;
}
ep->state = SCIFEP_BOUND;
......@@ -648,13 +647,12 @@ int __scif_connect(scif_epd_t epd, struct scif_port_id *dst, bool non_block)
err = -EISCONN;
break;
case SCIFEP_UNBOUND:
ep->port.port = scif_get_new_port();
if (!ep->port.port) {
err = -ENOSPC;
} else {
ep->port.node = scif_info.nodeid;
ep->conn_async_state = ASYNC_CONN_IDLE;
}
err = scif_get_new_port();
if (err < 0)
break;
ep->port.port = err;
ep->port.node = scif_info.nodeid;
ep->conn_async_state = ASYNC_CONN_IDLE;
/* Fall through */
case SCIFEP_BOUND:
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment