4.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Moni Shoua <mo...@mellanox.com>

commit bebb2a473a43c8f84a8210687d1cbdde503046d7 upstream.

In function addr_resolve() the namespace is a required input parameter
and not an output. It is passed later for searching the routing table
and device addresses. Also, it shouldn't be copied back to the caller.

Fixes: 565edd1d5555 ('IB/addr: Pass network namespace as a parameter')
Signed-off-by: Moni Shoua <mo...@mellanox.com>
Signed-off-by: Leon Romanovsky <l...@kernel.org>
Signed-off-by: Doug Ledford <dledf...@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 drivers/infiniband/core/addr.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -510,6 +510,11 @@ static int addr_resolve(struct sockaddr
        struct dst_entry *dst;
        int ret;
 
+       if (!addr->net) {
+               pr_warn_ratelimited("%s: missing namespace\n", __func__);
+               return -EINVAL;
+       }
+
        if (src_in->sa_family == AF_INET) {
                struct rtable *rt = NULL;
                const struct sockaddr_in *dst_in4 =
@@ -547,7 +552,6 @@ static int addr_resolve(struct sockaddr
        }
 
        addr->bound_dev_if = ndev->ifindex;
-       addr->net = dev_net(ndev);
        dev_put(ndev);
 
        return ret;


Reply via email to