hsr: fix error handling routine in hsr_dev_finalize()
authorTaehee Yoo <ap420073@gmail.com>
Sun, 22 Dec 2019 11:26:15 +0000 (11:26 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2020 09:20:07 +0000 (10:20 +0100)
commitfe974fba4ee5da900e30d2d5b9e80b4a4e137186
treef7af2fc09a0c98777a6e860108f8a62282117a30
parent9fa51bbdf7c241f969d3895e07ab45657fb5cc10
hsr: fix error handling routine in hsr_dev_finalize()

[ Upstream commit 1d19e2d53e8ed9e4c98fc95e0067492cda7288b0 ]

hsr_dev_finalize() is called to create new hsr interface.
There are some wrong error handling codes.

1. wrong checking return value of debugfs_create_{dir/file}.
These function doesn't return NULL. If error occurs in there,
it returns error pointer.
So, it should check error pointer instead of NULL.

2. It doesn't unregister interface if it fails to setup hsr interface.
If it fails to initialize hsr interface after register_netdevice(),
it should call unregister_netdevice().

3. Ignore failure of creation of debugfs
If creating of debugfs dir and file is failed, creating hsr interface
will be failed. But debugfs doesn't affect actual logic of hsr module.
So, ignoring this is more correct and this behavior is more general.

Fixes: c5a759117210 ("net/hsr: Use list_head (and rcu) instead of array for slave devices.")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/hsr/hsr_debugfs.c
net/hsr/hsr_device.c
net/hsr/hsr_main.h