From: Sudeep Dutt <sudeep.dutt@intel.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Sudeep Dutt <sudeep.dutt@intel.com>,
"Dixit, Ashutosh" <ashutosh.dixit@intel.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] misc: mic: SCIF Fix scif_get_new_port() error handling
Date: Wed, 08 Aug 2018 16:13:43 -0700 [thread overview]
Message-ID: <1533770023.18931.412.camel@localhost> (raw)
In-Reply-To: <20180802084222.xa3uwxld5en3cfzx@kili.mountain>
On Thu, 2018-08-02 at 01:42 -0700, Dan Carpenter wrote:
> 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>
> ---
> I have not tested this patch. Please review carefully.
Thanks for the patch Dan.
Reviewed-by: Sudeep Dutt <sudeep.dutt@intel.com>
>
> diff --git a/drivers/misc/mic/scif/scif_api.c b/drivers/misc/mic/scif/scif_api.c
> index 463f06d0b4ef..8dd0ccedeb94 100644
> --- a/drivers/misc/mic/scif/scif_api.c
> +++ b/drivers/misc/mic/scif/scif_api.c
> @@ -371,11 +371,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;
> @@ -649,13 +648,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:
> /*
prev parent reply other threads:[~2018-08-08 23:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-02 8:42 [PATCH] misc: mic: SCIF Fix scif_get_new_port() error handling Dan Carpenter
2018-08-08 23:13 ` Sudeep Dutt [this message]
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=1533770023.18931.412.camel@localhost \
--to=sudeep.dutt@intel.com \
--cc=arnd@arndb.de \
--cc=ashutosh.dixit@intel.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@embeddedor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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