2015-12-30 01:16:52

by Nicholas Krause

[permalink] [raw]
Subject: [PATCH RESEND] bnep:Add error paths for failed function calls in the function bnep_ctrl_set_netfilter

This adds the proper error paths for when the calls to the function
bnep_send_rsp fail by returning a error code and if this arises jump
to a new goto label out where we directly return the error code to
the caller to signal this failure.

Signed-off-by: Nicholas Krause <[email protected]>
---
net/bluetooth/bnep/core.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 1641367..8edfd75 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -103,6 +103,7 @@ static inline void bnep_set_default_proto_filter(struct bnep_session *s)
static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len)
{
int n;
+ int err = 0;

if (len < 2)
return -EILSEQ;
@@ -136,14 +137,19 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len
if (n == 0)
bnep_set_default_proto_filter(s);

- bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_SUCCESS);
+ err = bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_SUCCESS);
+ if (err)
+ goto out;
} else {
- bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_FILTER_LIMIT_REACHED);
+ err = bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_FILTER_LIMIT_REACHED);
+ if (err)
+ goto out;
}
#else
- bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_FILTER_UNSUPPORTED_REQ);
+ err = bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_FILTER_UNSUPPORTED_REQ);
#endif
- return 0;
+out:
+ return err;
}

static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
--
2.1.4