Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: fieldbus: Fix the error handling path in anybuss_host_common_probe()

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>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
7079b348 15210fd3

+1 -1
+1 -1
drivers/staging/fieldbus/anybuss/host.c
··· 1384 1384 goto err_device; 1385 1385 return cd; 1386 1386 err_device: 1387 - device_unregister(&cd->client->dev); 1387 + put_device(&cd->client->dev); 1388 1388 err_kthread: 1389 1389 kthread_stop(cd->qthread); 1390 1390 err_reset: