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@xxxxxxxxxx> --- drivers/staging/unisys/visorbus/visorbus_main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index cb147fa..c9b8637 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1193,17 +1193,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; @@ -1213,8 +1210,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) { @@ -1230,11 +1227,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. -- 2.5.0 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel