Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4869214pjb; Mon, 27 Jul 2020 07:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCjG407qTgAE3PBO6Nl7QhwdL7CA4TRZlfHo2aD3ZG6hs+9/b6zACv6o6efmlUZJga3A1b X-Received: by 2002:a17:906:ecb6:: with SMTP id qh22mr19837352ejb.230.1595859258207; Mon, 27 Jul 2020 07:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859258; cv=none; d=google.com; s=arc-20160816; b=dtJB97i/iWfLjM1jU+uQ/tiobxmEmHKiZFnd+YNEp4khGSqIHE+nhCaUTM6p+n2oJt 1D/+MM/NiR7/bvYbx57RpBBEZupfo4LAdR3cVvmFg1Anl8bB2661YaaheRuD+Ntw5IRO KzPwdUBE+SUTvpj2Zk92NpZw1xVd0EVfEN9KjV43l0YzAc1NFgoSsQQofiFJaYfUcVfR rcqyz6Q12XAnNmW0w3UdOhaS85EFq+SjNbG+Y6X/qMyy2ahiD/fErrME9aMruZNO5433 ubqpvx85ZSn7GPZNvKfAEDKTF34F+/7MSeLnbX8Cdj7qvBMv9fRAm7jC15e3K2Ytfvz7 iVDA== 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=UhRQTaCu9werLyT1EpDjDzSCPSzI6+UVwLhe0N/fE2A=; b=zlGt7PD+08ByBKuGlueZszDMJLpoNIczQ+Jnfb1h/9zWMU/2ieICgikpx65NkdWJEt v4M1E7ZCdWEIzbaEbi3VzoWXZbZv9WpKN5iTf//v0OCeTMAJTKsB7tXF4IYf2qSe16IR hYgrCTjJZgAbfgJUEHib4dKKfynXi2y+LmArUjPmhkN0BLUVBXcM9wulds2Rvi1r+LUE TJ+HqB+q2IZJW3wgceovs5T1vQtemarlbh/bS9xF12sVdBVp4vp030V/YTumgsx1OT64 KDD8eG4ruoZkKGlpcPSMSchbJbrhUCp/jjSsyQqJMyza2ecyOwaR0lUIl3LdVYHiLmX+ UwOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ugkw8AXW; 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 r24si2425383ejs.604.2020.07.27.07.13.55; Mon, 27 Jul 2020 07:14:18 -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=Ugkw8AXW; 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 S1729264AbgG0OKe (ORCPT + 99 others); Mon, 27 Jul 2020 10:10:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:33296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729851AbgG0OK2 (ORCPT ); Mon, 27 Jul 2020 10:10:28 -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 B4EBA2073E; Mon, 27 Jul 2020 14:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859027; bh=DKPMavGPBrYM78YOsHIPRxg7fswAFpWf5gmyCUqE340=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ugkw8AXWrSltSCWzdiW/grtxd0MhxXfhp/sGvyAqTrZFiz3J3E4ExCjffhuBzVIz4 fx2G+Oze4UzOMf6bDk/48/0l8aN0xLDMUVvvd3rS3Ou1tOB5DpNq92JImsvlZcnciA gV2OkkH/FOSRjo9fBlnt03EtycD9Ob9DLcan4/6Q= 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 4.19 39/86] bonding: check return value of register_netdevice() in bond_newlink() Date: Mon, 27 Jul 2020 16:04:13 +0200 Message-Id: <20200727134916.390664502@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134914.312934924@linuxfoundation.org> References: <20200727134914.312934924@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 6b9ad86732188..fbcd8a752ee70 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c @@ -451,11 +451,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