Skip to content

Commit a39284a

Browse files
Dan Carpentergregkh
authored andcommitted
misc: mic: SCIF Fix scif_get_new_port() error handling
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: e9089f4 ("misc: mic: SCIF open close bind and listen APIs") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0171114 commit a39284a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

drivers/misc/mic/scif/scif_api.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,10 @@ int scif_bind(scif_epd_t epd, u16 pn)
371371
goto scif_bind_exit;
372372
}
373373
} else {
374-
pn = scif_get_new_port();
375-
if (!pn) {
376-
ret = -ENOSPC;
374+
ret = scif_get_new_port();
375+
if (ret < 0)
377376
goto scif_bind_exit;
378-
}
377+
pn = ret;
379378
}
380379

381380
ep->state = SCIFEP_BOUND;
@@ -649,13 +648,12 @@ int __scif_connect(scif_epd_t epd, struct scif_port_id *dst, bool non_block)
649648
err = -EISCONN;
650649
break;
651650
case SCIFEP_UNBOUND:
652-
ep->port.port = scif_get_new_port();
653-
if (!ep->port.port) {
654-
err = -ENOSPC;
655-
} else {
656-
ep->port.node = scif_info.nodeid;
657-
ep->conn_async_state = ASYNC_CONN_IDLE;
658-
}
651+
err = scif_get_new_port();
652+
if (err < 0)
653+
break;
654+
ep->port.port = err;
655+
ep->port.node = scif_info.nodeid;
656+
ep->conn_async_state = ASYNC_CONN_IDLE;
659657
/* Fall through */
660658
case SCIFEP_BOUND:
661659
/*

0 commit comments

Comments
 (0)