Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4882647pjb; Mon, 27 Jul 2020 07:31:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9KzhjQSYqolNpfbw3ZNrQ1RODO7xsAKQL0xqa47xoR9r7O5gG9wNZ4V0/wrxD8iwMyfFq X-Received: by 2002:aa7:cd08:: with SMTP id b8mr5192281edw.228.1595860297232; Mon, 27 Jul 2020 07:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860297; cv=none; d=google.com; s=arc-20160816; b=Y/RQW2ZuwvENSb7K7iKsWJM+3eL9k04Zv8Ryj8cuZ3UgvfzqcApmu93lHtFWB5GyLL XeBrbD/pSw8qeyE3uPie9dlB2WEnObqTMbP6ppVrqinTpbsP9HSOU7m4lscvYkWlfC5d W9bvfAwKMgNb0DwivY8J6pv9G0s1buML+FkOPpaU6q/C1wTrlH/s/ND/WeSuPDjuwREc tISGfEz1qt1Om68FzA4b/X+3LhGYAQzJTC/D2m8imBELYeIaMjK0d0W/SxTWudvhfI0Z SZ7ZVqGIXf4WJR2k5VwzLDZfgvxNzYRI6hjxM6FoC9SmjErPmqwRSWGcKlQue9WQO8yK kiag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tW2HMQyQWz5MB6/P+cN08+AmLpWu7tBTzVikhYsb6EU=; b=MAIOd/yYzd2Ox50JG4AjlZDTTiwffPKwJz9i46tdlXJghfK+kIJ7s94SvBjztt3UD1 CZ/OZtyiVHs3FtH989XQfSJx3ccDlYAnVhG09wzM18Z22NEF2REOE+UWWUPrfCJ+dS1N LnXFwbPmMHn/rGEplfr+eQFYOhslRbWxgq6PWWhSl1TuzPB+BK1c95rwTAXQZPCwmaYE LhUgNh8uUsebtFxkgkQWThAPD+55b7kOPFD1IDTeHCJ5kRirIIqn3aWtYM1/fkKA+pi4 kdQWGGwCq7e2DJVL7QuMHCNg2yGUdqqKwyAXLtGHs71x8MCzIjGfQy7zImJL0UbXrLpD knkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G3b1xWsL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mj22si2846207ejb.738.2020.07.27.07.31.15; Mon, 27 Jul 2020 07:31:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G3b1xWsL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731969AbgG0OaE (ORCPT + 99 others); Mon, 27 Jul 2020 10:30:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:51570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731931AbgG0OWf (ORCPT ); Mon, 27 Jul 2020 10:22:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E3F22075A; Mon, 27 Jul 2020 14:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859755; bh=XxeXK1ZqMAk6niV3nqN1IkP63mf7KUrh+w6xEhY77Ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3b1xWsLoZ1yTG3lvet8pZnWhFBsT3MAa32skPviJLaHOyoLX6ArdUXCUsLor27iC pt0HQNLGW+HQhAIFG8iOqn84LhVZggxIvTMNOxrS7mYJ+88SZIMd+kEH48m8cdJQ+B jVI2j8VcwdCIISIgDPjKv7vnbdCGES/Den06PgQ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Beniamino Galvani , Taehee Yoo , Jay Vosburgh , Cong Wang , "David S. Miller" , Sasha Levin , syzbot+bbc3a11c4da63c1b74d6@syzkaller.appspotmail.com Subject: [PATCH 5.7 093/179] bonding: check return value of register_netdevice() in bond_newlink() Date: Mon, 27 Jul 2020 16:04:28 +0200 Message-Id: <20200727134937.197793793@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cong Wang [ Upstream commit c75d1d5248c0c97996051809ad0e9f154ba5d76e ] Very similar to commit 544f287b8495 ("bonding: check error value of register_netdevice() immediately"), we should immediately check the return value of register_netdevice() before doing anything else. Fixes: 005db31d5f5f ("bonding: set carrier off for devices created through netlink") Reported-and-tested-by: syzbot+bbc3a11c4da63c1b74d6@syzkaller.appspotmail.com Cc: Beniamino Galvani Cc: Taehee Yoo Cc: Jay Vosburgh Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/bonding/bond_netlink.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index b43b51646b11a..f0f9138e967f3 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c @@ -456,11 +456,10 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev, return err; err = register_netdevice(bond_dev); - - netif_carrier_off(bond_dev); if (!err) { struct bonding *bond = netdev_priv(bond_dev); + netif_carrier_off(bond_dev); bond_work_init_all(bond); } -- 2.25.1