]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
misc: mic: SCIF Fix scif_get_new_port() error handling
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 2 Aug 2018 08:42:22 +0000 (11:42 +0300)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:47:27 +0000 (19:47 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836117
[ Upstream commit a39284ae9d2ad09975c8ae33f1bd0f05fbfbf6ee ]

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: e9089f43c9a7 ("misc: mic: SCIF open close bind and listen APIs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/misc/mic/scif/scif_api.c

index ddc9e4b08b5cd809f4ce6e43fe1ec313dfb75e0d..56efa9d18a9afec2ddaea8bb76fc7ec34c14ce78 100644 (file)
@@ -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:
                /*