misc: ocxl: use put_device() instead of device_unregister()

if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Arvind Yadav 2018-03-12 17:06:53 +05:30 committed by Greg Kroah-Hartman
parent 5fbe9f35df
commit 474cca5fd8

View File

@ -519,7 +519,7 @@ static struct ocxl_fn *init_function(struct pci_dev *dev)
rc = device_register(&fn->dev); rc = device_register(&fn->dev);
if (rc) { if (rc) {
deconfigure_function(fn); deconfigure_function(fn);
device_unregister(&fn->dev); put_device(&fn->dev);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
return fn; return fn;