staging: unisys: get rid of goto in create_bus_instance()

Remove the unnecessary rc and goto messiness, and just handle freeing
the memory before returning an error in the one place where that needs
to happen.

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Benjamin Romer 2016-02-23 10:01:52 -05:00 committed by Greg Kroah-Hartman
parent f99d3308c5
commit c2c667d6bd
1 changed files with 4 additions and 12 deletions

View File

@ -1197,17 +1197,14 @@ fix_vbus_dev_info(struct visor_device *visordev)
static int
create_bus_instance(struct visor_device *dev)
{
int rc;
int id = dev->chipset_bus_no;
struct spar_vbus_headerinfo *hdr_info;
POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL);
if (!hdr_info) {
rc = -1;
goto away;
}
if (!hdr_info)
return -ENOMEM;
dev_set_name(&dev->device, "visorbus%d", id);
dev->device.bus = &visorbus_type;
@ -1217,8 +1214,8 @@ create_bus_instance(struct visor_device *dev)
if (device_register(&dev->device) < 0) {
POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id,
POSTCODE_SEVERITY_ERR);
rc = -1;
goto away_mem;
kfree(hdr_info);
return -ENODEV;
}
if (get_vbus_header_info(dev->visorchannel, hdr_info) >= 0) {
@ -1234,11 +1231,6 @@ create_bus_instance(struct visor_device *dev)
list_add_tail(&dev->list_all, &list_all_bus_instances);
dev_set_drvdata(&dev->device, dev);
return 0;
away_mem:
kfree(hdr_info);
away:
return rc;
}
/** Remove a device instance for the visor bus itself.