Skip to content

Commit

Permalink
i2c: sis630: Fix an error handling path in sis630_probe()
Browse files Browse the repository at this point in the history
If i2c_add_adapter() fails, the request_region() call in sis630_setup()
must be undone by a corresponding release_region() call, as done in the
remove function.

Fixes: 1da177e ("Linux-2.6.12-rc2")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/3d607601f2c38e896b10207963c6ab499ca5c307.1741033587.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
  • Loading branch information
Christophe JAILLET authored and Andi Shyti committed Mar 12, 2025
1 parent 6e55caa commit 2b22459
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/i2c/busses/i2c-sis630.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ MODULE_DEVICE_TABLE(pci, sis630_ids);

static int sis630_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
int ret;

if (sis630_setup(dev)) {
dev_err(&dev->dev,
"SIS630 compatible bus not detected, "
Expand All @@ -522,7 +524,15 @@ static int sis630_probe(struct pci_dev *dev, const struct pci_device_id *id)
snprintf(sis630_adapter.name, sizeof(sis630_adapter.name),
"SMBus SIS630 adapter at %04x", smbus_base + SMB_STS);

return i2c_add_adapter(&sis630_adapter);
ret = i2c_add_adapter(&sis630_adapter);
if (ret)
goto release_region;

return 0;

release_region:
release_region(smbus_base + SMB_STS, SIS630_SMB_IOREGION);
return ret;
}

static void sis630_remove(struct pci_dev *dev)
Expand Down

0 comments on commit 2b22459

Please sign in to comment.