net: ipmr: fix setsockopt error return
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Thu, 26 Nov 2015 14:23:49 +0000 (15:23 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Nov 2015 20:26:22 +0000 (15:26 -0500)
We can have both errors and we'll return the second one, fix it to
return an error at a time as it's normal. I've overlooked this in my
previous set.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ipmr.c

index 322fdc6ac75b3fb354e5a3b48e663fa351e080dc..6c24a16299c73c3b5b2151f1047a87edf119bde3 100644 (file)
@@ -1284,12 +1284,14 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
 
        switch (optname) {
        case MRT_INIT:
-               if (optlen != sizeof(int))
+               if (optlen != sizeof(int)) {
                        ret = -EINVAL;
-               if (rtnl_dereference(mrt->mroute_sk))
+                       break;
+               }
+               if (rtnl_dereference(mrt->mroute_sk)) {
                        ret = -EADDRINUSE;
-               if (ret)
                        break;
+               }
 
                ret = ip_ra_control(sk, 1, mrtsock_destruct);
                if (ret == 0) {