OSDN Git Service

bonding: init notify_work earlier to avoid uninitialized use
authorJohannes Berg <johannes.berg@intel.com>
Mon, 17 May 2021 14:13:35 +0000 (16:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jun 2021 09:54:57 +0000 (11:54 +0200)
commitf583748c2a4a1dc731812ae2c12cadca5c1a88b5
treec5619867ab34de9e0494dfa6c6fe09456023b0fd
parentbf78e25bd3f487208e042c67c8a31706c2dba265
bonding: init notify_work earlier to avoid uninitialized use

[ Upstream commit 35d96e631860226d5dc4de0fad0a415362ec2457 ]

If bond_kobj_init() or later kzalloc() in bond_alloc_slave() fail,
then we call kobject_put() on the slave->kobj. This in turn calls
the release function slave_kobj_release() which will always try to
cancel_delayed_work_sync(&slave->notify_work), which shouldn't be
done on an uninitialized work struct.

Always initialize the work struct earlier to avoid problems here.

Syzbot bisected this down to a completely pointless commit, some
fault injection may have been at work here that caused the alloc
failure in the first place, which may interact badly with bisect.

Reported-by: syzbot+bfda097c12a00c8cae67@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/bonding/bond_main.c