IB/cma: Add a missing rcu_read_unlock()
authorBart Van Assche <[email protected]>
Fri, 20 Nov 2015 19:04:12 +0000 (11:04 -0800)
committerDoug Ledford <[email protected]>
Tue, 8 Dec 2015 17:14:43 +0000 (12:14 -0500)
Ensure that validate_ipv4_net_dev() calls rcu_read_unlock() if
fib_lookup() fails. Detected by sparse. Compile-tested only.

Fixes: "IB/cma: Validate routing of incoming requests" (commit f887f2ac87c2).
Cc: Haggai Eran <[email protected]>
Cc: stable <[email protected]>
Reviewed-by: Sagi Grimberg <[email protected]>
Reviewed-by: Haggai Eran <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
drivers/infiniband/core/cma.c

index 944cd90417bcc9b2a51d27f903feffad6f2307ea..d2d5d004f16dbb11fc4a57b5ce47004da567a137 100644 (file)
@@ -1126,10 +1126,7 @@ static bool validate_ipv4_net_dev(struct net_device *net_dev,
 
        rcu_read_lock();
        err = fib_lookup(dev_net(net_dev), &fl4, &res, 0);
-       if (err)
-               return false;
-
-       ret = FIB_RES_DEV(res) == net_dev;
+       ret = err == 0 && FIB_RES_DEV(res) == net_dev;
        rcu_read_unlock();
 
        return ret;