staging: fieldbus: Fix the error handling path in anybuss_host_common_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 22 Apr 2022 06:48:18 +0000 (08:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:36:04 +0000 (18:36 +0200)
commit52e848568aa37c649bce5e3b380362523825616e
tree746ca18dbae870aa2134e568f1a4ab9b57a80b35
parent10243224fd457dc5509dd929c162f8a1761bd18e
staging: fieldbus: Fix the error handling path in anybuss_host_common_probe()

[ Upstream commit 7079b3483a17be2cfba64cbd4feb1b7ae07f1ea7 ]

If device_register() fails, device_unregister() should not be called
because it will free some resources that are not allocated.
put_device() should be used instead.

Fixes: 308ee87a2f1e ("staging: fieldbus: anybus-s: support HMS Anybus-S bus")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/5401a519608d6e1a4e7435c20f4f20b0c5c36c23.1650610082.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/fieldbus/anybuss/host.c