From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "stable@vger.kernel.org" <stable@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL 4.9 01/62] misc: mic: SCIF Fix scif_get_new_port() error handling
Date: Sun, 2 Sep 2018 13:08:34 +0000 [thread overview]
Message-ID: <20180902065131.183542-1-alexander.levin@microsoft.com> (raw)
From: Dan Carpenter <dan.carpenter@oracle.com>
[ 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>
---
drivers/misc/mic/scif/scif_api.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/misc/mic/scif/scif_api.c b/drivers/misc/mic/scif/scif_api.c
index ddc9e4b08b5c..56efa9d18a9a 100644
--- a/drivers/misc/mic/scif/scif_api.c
+++ b/drivers/misc/mic/scif/scif_api.c
@@ -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:
/*
--
2.17.1
next reply other threads:[~2018-09-02 17:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-02 13:08 Sasha Levin [this message]
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 02/62] ethtool: Remove trailing semicolon for static inline Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 03/62] Bluetooth: h5: Fix missing dependency on BT_HCIUART_SERDEV Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 04/62] gpio: tegra: Move driver registration to subsys_init level Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 05/62] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 06/62] scsi: target: fix __transport_register_session locking Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 07/62] media: usbtv: use irqsave() in USB's complete callback Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 08/62] md/raid5: fix data corruption of replacements after originals dropped Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 09/62] timers: Clear timer_base::must_forward_clk with timer_base::lock held Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.9 10/62] misc: ti-st: Fix memory leak in the error path of probe() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180902065131.183542-1-alexander.levin@microsoft.com \
--to=alexander.levin@microsoft.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).