net: hso: add failure handler for add_net_device
authorZiyang Xuan <william.xuanziyang@huawei.com>
Thu, 2 Sep 2021 08:36:09 +0000 (16:36 +0800)
committerDom Cobley <popcornmix@gmail.com>
Thu, 14 Oct 2021 11:32:59 +0000 (12:32 +0100)
commit51cb7575ae091520ad552a06952be5e1facda383
tree97543a49318ebe47195f11279de7f8a40f8315cf
parentdcd1ed4a7135155f0b43cd2a142a68ffea866c3f
net: hso: add failure handler for add_net_device

[ Upstream commit ecdc28defc46af476566fffd9e5cb4495a2f176e ]

If the network devices connected to the system beyond
HSO_MAX_NET_DEVICES. add_net_device() in hso_create_net_device()
will be failed for the network_table is full. It will lead to
business failure which rely on network_table, for example,
hso_suspend() and hso_resume(). It will also lead to memory leak
because resource release process can not search the hso_device
object from network_table in hso_free_interface().

Add failure handler for add_net_device() in hso_create_net_device()
to solve the above problems.

Fixes: 72dc1c096c70 ("HSO: add option hso driver")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/usb/hso.c