From: Benjamin Romer Date: Tue, 23 Feb 2016 15:01:52 +0000 (-0500) Subject: staging: unisys: get rid of goto in create_bus_instance() X-Git-Tag: next-20160301~20^2~7 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c2c667d6bd78794bc3ee63939786caafe2169a4b;p=karo-tx-linux.git 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index f81da4d2e657..59cef7779a2d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -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.