[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240216174646.6a0dd168@kernel.org>
Date: Fri, 16 Feb 2024 17:46:46 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: David Wei <dw@...idwei.uk>
Cc: Jiri Pirko <jiri@...nulli.us>, Sabrina Dubroca <sd@...asysnail.net>,
netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>, Eric
Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next v11 1/3] netdevsim: allow two netdevsim ports
to be connected
On Thu, 15 Feb 2024 11:43:23 -0800 David Wei wrote:
> + ns_a = get_net_ns_by_fd(netnsfd_a);
> + if (IS_ERR(ns_a)) {
> + pr_err("Could not find netns with fd: %d\n", netnsfd_a);
> + return -EINVAL;
> + }
> +
> + ns_b = get_net_ns_by_fd(netnsfd_b);
> + if (IS_ERR(ns_b)) {
> + pr_err("Could not find netns with fd: %d\n", netnsfd_b);
> + return -EINVAL;
> + }
> +
> + err = -EINVAL;
> + rtnl_lock();
> + dev_a = __dev_get_by_index(ns_a, ifidx_a);
> + if (!dev_a) {
> + pr_err("Could not find device with ifindex %u in netnsfd %d\n", ifidx_a, netnsfd_a);
> + goto out_put_netns_a;
> + }
> +
> + if (!netdev_is_nsim(dev_a)) {
> + pr_err("Device with ifindex %u in netnsfd %d is not a netdevsim\n", ifidx_a, netnsfd_a);
> + goto out_put_netns_a;
> + }
> +
> + dev_b = __dev_get_by_index(ns_b, ifidx_b);
> + if (!dev_b) {
> + pr_err("Could not find device with ifindex %u in netnsfd %d\n", ifidx_b, netnsfd_b);
> + goto out_put_netns_b;
> + }
> +
> + if (!netdev_is_nsim(dev_b)) {
> + pr_err("Device with ifindex %u in netnsfd %d is not a netdevsim\n", ifidx_b, netnsfd_b);
> + goto out_put_netns_b;
> + }
> +
> + if (dev_a == dev_b) {
> + pr_err("Cannot link a netdevsim to itself\n");
> + goto out_put_netns_b;
You need to fix the gotos here :( You're leaking the references
to the namespaces on error paths :(
--
pw-bot: cr
Powered by blists - more mailing lists