public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] lwtunnel: fix error path in lwtunnel_fill_encap()
@ 2017-04-28 13:03 Dan Carpenter
  2017-04-29 13:03 ` David Ahern
  2017-05-01  2:42 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-04-28 13:03 UTC (permalink / raw)
  To: David S. Miller, Pan Bian
  Cc: Roopa Prabhu, David Ahern, Robert Shearman, Tom Herbert,
	David Lebrun, netdev, kernel-janitors

We recently added a check to see if nla_nest_start() fails.  There are
two issues with that.  First, if it fails then I don't think we should
call nla_nest_cancel().  Second, it's slightly convoluted but the
current code returns success but we should return -EMSGSIZE instead.

Fixes: a50fe0ffd76f ("lwtunnel: check return value of nla_nest_start")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
index 5cbed3816229..cfae3d5fe11f 100644
--- a/net/core/lwtunnel.c
+++ b/net/core/lwtunnel.c
@@ -203,7 +203,7 @@ int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate)
 {
 	const struct lwtunnel_encap_ops *ops;
 	struct nlattr *nest;
-	int ret = -EINVAL;
+	int ret;
 
 	if (!lwtstate)
 		return 0;
@@ -212,10 +212,11 @@ int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate)
 	    lwtstate->type > LWTUNNEL_ENCAP_MAX)
 		return 0;
 
-	ret = -EOPNOTSUPP;
 	nest = nla_nest_start(skb, RTA_ENCAP);
 	if (!nest)
-		goto nla_put_failure;
+		return -EMSGSIZE;
+
+	ret = -EOPNOTSUPP;
 	rcu_read_lock();
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
 	if (likely(ops && ops->fill_encap))

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] lwtunnel: fix error path in lwtunnel_fill_encap()
  2017-04-28 13:03 [PATCH net-next] lwtunnel: fix error path in lwtunnel_fill_encap() Dan Carpenter
@ 2017-04-29 13:03 ` David Ahern
  2017-05-01  2:42 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2017-04-29 13:03 UTC (permalink / raw)
  To: Dan Carpenter, David S. Miller, Pan Bian
  Cc: Roopa Prabhu, Robert Shearman, Tom Herbert, David Lebrun, netdev,
	kernel-janitors

On 4/28/17 7:03 AM, Dan Carpenter wrote:
> We recently added a check to see if nla_nest_start() fails.  There are
> two issues with that.  First, if it fails then I don't think we should
> call nla_nest_cancel().  Second, it's slightly convoluted but the
> current code returns success but we should return -EMSGSIZE instead.
> 
> Fixes: a50fe0ffd76f ("lwtunnel: check return value of nla_nest_start")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 

Acked-by: David Ahern <dsa@cumulusnetworks.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] lwtunnel: fix error path in lwtunnel_fill_encap()
  2017-04-28 13:03 [PATCH net-next] lwtunnel: fix error path in lwtunnel_fill_encap() Dan Carpenter
  2017-04-29 13:03 ` David Ahern
@ 2017-05-01  2:42 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-05-01  2:42 UTC (permalink / raw)
  To: dan.carpenter
  Cc: bianpan2016, roopa, dsa, rshearma, tom, david.lebrun, netdev,
	kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 28 Apr 2017 16:03:48 +0300

> We recently added a check to see if nla_nest_start() fails.  There are
> two issues with that.  First, if it fails then I don't think we should
> call nla_nest_cancel().  Second, it's slightly convoluted but the
> current code returns success but we should return -EMSGSIZE instead.
> 
> Fixes: a50fe0ffd76f ("lwtunnel: check return value of nla_nest_start")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-01  2:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-28 13:03 [PATCH net-next] lwtunnel: fix error path in lwtunnel_fill_encap() Dan Carpenter
2017-04-29 13:03 ` David Ahern
2017-05-01  2:42 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox