Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp575621iof; Mon, 6 Jun 2022 08:46:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9tEooiNeTP3X7OLtb25hwuQzpW6zvg+hVcHOv/NJc+xIJsf1+DyjC0C6tjQ3XJxY4gfrE X-Received: by 2002:a17:902:f710:b0:167:7a06:b2ce with SMTP id h16-20020a170902f71000b001677a06b2cemr7203896plo.104.1654530396035; Mon, 06 Jun 2022 08:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654530396; cv=none; d=google.com; s=arc-20160816; b=00zOzCovf4VFhbNjQTZV8cBC4srEjqnghCb5Tqj+0hGgt+ObWcTk+8C5Rx8S8dz3d8 jLvuOTrBddhyOGH84oXuRLvh1qKy56Cq1P3DmknbcF76h/B6MtdwV7X7iSadvtSWjjg4 pTRrHvk+wnU0jMPIKlmgvPqs7hi7cd7tJvjr99DIvAodGqLAp9HxLSzTcmkehjStc2ZX XR980PEsEccjau6k6eKOi8JLdxnR0kzBynXuTv0BRGVggUWnMQzcFDtFq8RcJF1GdgwD rd900tKkFqpkhEoPHak8K0jQjLKqOnZiUhhmQOea6yKoKXAikk3C52MXAnmnkUO38XCM 7upw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+hANCxUkjtJekam2HLSgzp8bKfmmuJSpp+YeIM4LYb4=; b=mVGtJ5cCgb4jk5kk7jywtENfq7Y4L9sz/Wy75bZ5ENKsyUwkD0CN7khGbJNW6K04qt mhkb9qUk8PvukOqLcEQ1Ec49i6Y/vlWQ4w/Ey0ettB43WXuRdYmYxomcvi9VnJhpQRDS M9Gq//pox4pp2fshEk4EpoPAyJLkJQbgE6R1lTIg77MzIrzIdG6qjg2nQuMx5q+EKmDC 8edhJE1Wvsn3VdlaXImC2HzMZ5ePKuJqz/mTCK/Unbr+eUUp0LmIv7GviW62cduBMSzx H+a5Vklbsyv9xYuXDrzqb5Wo1+GBBqe60B6/nBgGXDy+ol+wEk5nLs73z7cPRn/rL3Xj RatQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="LP6zas/z"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o21-20020a170903211500b00161d4849aa6si18553128ple.390.2022.06.06.08.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:46:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="LP6zas/z"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 387F73525D; Mon, 6 Jun 2022 08:30:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240848AbiFFP3E (ORCPT + 99 others); Mon, 6 Jun 2022 11:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240813AbiFFP1c (ORCPT ); Mon, 6 Jun 2022 11:27:32 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78999646C for ; Mon, 6 Jun 2022 08:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654529243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+hANCxUkjtJekam2HLSgzp8bKfmmuJSpp+YeIM4LYb4=; b=LP6zas/zUl80uedikXfB3MrVyvDEx5A08xTax46joCX5rzoyikPrXGX3DW4/pPYluoFuOv NOIvf/WZpsLcvvULoOlocifCRV4wlvhZxQjTxDGEjABPk9KOsaB9hsV24LKitoF/xL19YE mJDgyhBRxSSjkL5KBawghsMOrwP7aSo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-dqgEHCpIPrSZASKGAJipqA-1; Mon, 06 Jun 2022 11:27:18 -0400 X-MC-Unique: dqgEHCpIPrSZASKGAJipqA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19FE329ABA31; Mon, 6 Jun 2022 15:27:18 +0000 (UTC) Received: from jtoppins.rdu.csb (unknown [10.22.34.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA66F82882; Mon, 6 Jun 2022 15:27:17 +0000 (UTC) From: Jonathan Toppins To: netdev@vger.kernel.org Cc: jtoppins@redhat.com, Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [net-next 2/2] bonding: cleanup bond_create Date: Mon, 6 Jun 2022 11:26:53 -0400 Message-Id: <3f69118ff14ac0608810dac8dc1493559cf81640.1654528729.git.jtoppins@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Setting RLB_NULL_INDEX is not needed as this is done in bond_alb_initialize which is called by bond_open. Also reduce the number of rtnl_unlock calls by just using the standard goto cleanup path. Signed-off-by: Jonathan Toppins --- drivers/net/bonding/bond_main.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f85372adf042..3d427183ec8e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -6218,45 +6218,33 @@ int bond_create(struct net *net, const char *name) { struct net_device *bond_dev; struct bonding *bond; - struct alb_bond_info *bond_info; - int res; + int res = -ENOMEM; rtnl_lock(); bond_dev = alloc_netdev_mq(sizeof(struct bonding), name ? name : "bond%d", NET_NAME_UNKNOWN, bond_setup, tx_queues); - if (!bond_dev) { - pr_err("%s: eek! can't alloc netdev!\n", name); - rtnl_unlock(); - return -ENOMEM; - } + if (!bond_dev) + goto out; - /* - * Initialize rx_hashtbl_used_head to RLB_NULL_INDEX. - * It is set to 0 by default which is wrong. - */ bond = netdev_priv(bond_dev); - bond_info = &(BOND_ALB_INFO(bond)); - bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX; - dev_net_set(bond_dev, net); bond_dev->rtnl_link_ops = &bond_link_ops; res = register_netdevice(bond_dev); if (res < 0) { free_netdev(bond_dev); - rtnl_unlock(); - - return res; + goto out; } netif_carrier_off(bond_dev); bond_work_init_all(bond); +out: rtnl_unlock(); - return 0; + return res; } static int __net_init bond_net_init(struct net *net) -- 2.27.0