Commit 56411c0f authored by Matthijs Kooijman's avatar Matthijs Kooijman Committed by Mauro Carvalho Chehab

[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
f27b853e ("[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 b31b0219 ("[media] ene_ir: Fix
driver initialisation") and commit
9ef449c6 ("[media] rc: Postpone ISR
registration").
Signed-off-by: default avatarMatthijs Kooijman <matthijs@stdin.nl>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 895507c1
...@@ -1003,7 +1003,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) ...@@ -1003,7 +1003,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
rdev = rc_allocate_device(); rdev = rc_allocate_device();
if (!dev || !rdev) if (!dev || !rdev)
goto error1; goto failure;
/* validate resources */ /* validate resources */
error = -ENODEV; error = -ENODEV;
...@@ -1014,10 +1014,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) ...@@ -1014,10 +1014,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
if (!pnp_port_valid(pnp_dev, 0) || if (!pnp_port_valid(pnp_dev, 0) ||
pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE)
goto error; goto failure;
if (!pnp_irq_valid(pnp_dev, 0)) if (!pnp_irq_valid(pnp_dev, 0))
goto error; goto failure;
spin_lock_init(&dev->hw_lock); spin_lock_init(&dev->hw_lock);
...@@ -1033,7 +1033,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) ...@@ -1033,7 +1033,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
/* detect hardware version and features */ /* detect hardware version and features */
error = ene_hw_detect(dev); error = ene_hw_detect(dev);
if (error) if (error)
goto error; goto failure;
if (!dev->hw_learning_and_tx_capable && txsim) { if (!dev->hw_learning_and_tx_capable && txsim) {
dev->hw_learning_and_tx_capable = true; dev->hw_learning_and_tx_capable = true;
...@@ -1078,30 +1078,27 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) ...@@ -1078,30 +1078,27 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
/* claim the resources */ /* claim the resources */
error = -EBUSY; error = -EBUSY;
if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) {
dev->hw_io = -1; goto failure;
dev->irq = -1;
goto error;
} }
dev->irq = pnp_irq(pnp_dev, 0); dev->irq = pnp_irq(pnp_dev, 0);
if (request_irq(dev->irq, ene_isr, if (request_irq(dev->irq, ene_isr,
IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) { IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) {
dev->irq = -1; goto failure2;
goto error;
} }
error = rc_register_device(rdev); error = rc_register_device(rdev);
if (error < 0) if (error < 0)
goto error; goto failure3;
pr_notice("driver has been successfully loaded\n"); pr_notice("driver has been successfully loaded\n");
return 0; return 0;
error:
if (dev && dev->irq >= 0) failure3:
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
if (dev && dev->hw_io >= 0) failure2:
release_region(dev->hw_io, ENE_IO_SIZE); release_region(dev->hw_io, ENE_IO_SIZE);
error1: failure:
rc_free_device(rdev); rc_free_device(rdev);
kfree(dev); kfree(dev);
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment