[PATCH net] sit: Correctly return -ENOMEM from SIOCGETPRL ioctl.

Subsystems: networking [general], the rest

STALE3664d

2 messages, 2 authors, 2016-07-27 · open the first message on its own page

[PATCH net] sit: Correctly return -ENOMEM from SIOCGETPRL ioctl.

From: Phil Turnbull <hidden>
Date: 2016-07-27 13:58:30

-ENOMEM is never returned because the 'out' path unconditionally sets
'ret' to zero. Remove the 'out' path and return directly when the
allocation fails.

Fixes: 300aaeeaab5f ("[IPV6] SIT: Add SIOCGETPRL ioctl to get/dump PRL.")
Signed-off-by: Phil Turnbull <redacted>
---
 net/ipv6/sit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 0619ac70836d..a71514040bb4 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -320,8 +320,8 @@ static int ipip6_tunnel_get_prl(struct ip_tunnel *t,
 		 */
 		kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC);
 		if (!kp) {
-			ret = -ENOMEM;
-			goto out;
+			rcu_read_unlock();
+			return -ENOMEM;
 		}
 	}
 
@@ -337,7 +337,7 @@ static int ipip6_tunnel_get_prl(struct ip_tunnel *t,
 		if (kprl.addr != htonl(INADDR_ANY))
 			break;
 	}
-out:
+
 	rcu_read_unlock();
 
 	len = sizeof(*kp) * c;
-- 
2.9.0.rc2

Re: [PATCH net] sit: Correctly return -ENOMEM from SIOCGETPRL ioctl.

From: Cong Wang <hidden>
Date: 2016-07-27 16:28:50

On Wed, Jul 27, 2016 at 6:57 AM, Phil Turnbull [off-list ref] wrote:
quoted hunk
-ENOMEM is never returned because the 'out' path unconditionally sets
'ret' to zero. Remove the 'out' path and return directly when the
allocation fails.

Fixes: 300aaeeaab5f ("[IPV6] SIT: Add SIOCGETPRL ioctl to get/dump PRL.")
Signed-off-by: Phil Turnbull <redacted>
---
 net/ipv6/sit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 0619ac70836d..a71514040bb4 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -320,8 +320,8 @@ static int ipip6_tunnel_get_prl(struct ip_tunnel *t,
                 */
                kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC);
                if (!kp) {
-                       ret = -ENOMEM;
-                       goto out;
+                       rcu_read_unlock();
+                       return -ENOMEM;
                }
Or even better: we don't have to do the second kcalloc()
within rcu read lock, we can move it before rcu_read_lock()?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help