]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
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)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 26 Aug 2022 08:52:36 +0000 (10:52 +0200)
BugLink: https://bugs.launchpad.net/bugs/1982968
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/staging/fieldbus/anybuss/host.c

index 8a75f6642c78335bdfc39b7536a47f3365ad5bd9..0c41d1e0204fb06162c65c758543dfa58b7af11e 100644 (file)
@@ -1384,7 +1384,7 @@ anybuss_host_common_probe(struct device *dev,
                goto err_device;
        return cd;
 err_device:
-       device_unregister(&cd->client->dev);
+       put_device(&cd->client->dev);
 err_kthread:
        kthread_stop(cd->qthread);
 err_reset: