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

[media] ene-ir: Fix cleanup on probe failure

This makes the cleanup on probe failure more consistent with other
drivers. This is similar to what commit
f27b853ea24a9b70585f9251384d97929e6551c3 ("[media] rc: Fix invalid
free_region and/or free_irq on probe failure") did for some other
drivers.
In addition to making the cleanup more consistent, this also fixes a
case where (on a ene_hw_detect failure) free_region would be called on a
region that was not requested yet.
This last problem was probably introduced by the moving of code in
commit b31b021988fed9e3741a46918f14ba9b063811db ("[media] ene_ir: Fix
driver initialisation") and commit
9ef449c6b31bb6a8e6dedc24de475a3b8c79be20 ("[media] rc: Postpone ISR
registration").

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Matthijs Kooijman and committed by
Mauro Carvalho Chehab
56411c0f 895507c1

+13 -16
+13 -16
drivers/media/rc/ene_ir.c
··· 1003 1003 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); 1004 1004 rdev = rc_allocate_device(); 1005 1005 if (!dev || !rdev) 1006 - goto error1; 1006 + goto failure; 1007 1007 1008 1008 /* validate resources */ 1009 1009 error = -ENODEV; ··· 1014 1014 1015 1015 if (!pnp_port_valid(pnp_dev, 0) || 1016 1016 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) 1017 - goto error; 1017 + goto failure; 1018 1018 1019 1019 if (!pnp_irq_valid(pnp_dev, 0)) 1020 - goto error; 1020 + goto failure; 1021 1021 1022 1022 spin_lock_init(&dev->hw_lock); 1023 1023 ··· 1033 1033 /* detect hardware version and features */ 1034 1034 error = ene_hw_detect(dev); 1035 1035 if (error) 1036 - goto error; 1036 + goto failure; 1037 1037 1038 1038 if (!dev->hw_learning_and_tx_capable && txsim) { 1039 1039 dev->hw_learning_and_tx_capable = true; ··· 1078 1078 /* claim the resources */ 1079 1079 error = -EBUSY; 1080 1080 if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { 1081 - dev->hw_io = -1; 1082 - dev->irq = -1; 1083 - goto error; 1081 + goto failure; 1084 1082 } 1085 1083 1086 1084 dev->irq = pnp_irq(pnp_dev, 0); 1087 1085 if (request_irq(dev->irq, ene_isr, 1088 1086 IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) { 1089 - dev->irq = -1; 1090 - goto error; 1087 + goto failure2; 1091 1088 } 1092 1089 1093 1090 error = rc_register_device(rdev); 1094 1091 if (error < 0) 1095 - goto error; 1092 + goto failure3; 1096 1093 1097 1094 pr_notice("driver has been successfully loaded\n"); 1098 1095 return 0; 1099 - error: 1100 - if (dev && dev->irq >= 0) 1101 - free_irq(dev->irq, dev); 1102 - if (dev && dev->hw_io >= 0) 1103 - release_region(dev->hw_io, ENE_IO_SIZE); 1104 - error1: 1096 + 1097 + failure3: 1098 + free_irq(dev->irq, dev); 1099 + failure2: 1100 + release_region(dev->hw_io, ENE_IO_SIZE); 1101 + failure: 1105 1102 rc_free_device(rdev); 1106 1103 kfree(dev); 1107 1104 return error;