Skip to content

Commit f529944

Browse files
tititiou36Sasha Levin
authored andcommitted
i2c: ali15x3: Fix an error handling path in ali15x3_probe()
[ Upstream commit 6e55caa ] If i2c_add_adapter() fails, the request_region() call in ali15x3_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> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/9b2090cbcc02659f425188ea05f2e02745c4e67b.1741031878.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e180bee commit f529944

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

drivers/i2c/busses/i2c-ali15x3.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ MODULE_DEVICE_TABLE (pci, ali15x3_ids);
473473

474474
static int ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id)
475475
{
476+
int ret;
477+
476478
if (ali15x3_setup(dev)) {
477479
dev_err(&dev->dev,
478480
"ALI15X3 not detected, module not inserted.\n");
@@ -484,7 +486,15 @@ static int ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id)
484486

485487
snprintf(ali15x3_adapter.name, sizeof(ali15x3_adapter.name),
486488
"SMBus ALI15X3 adapter at %04x", ali15x3_smba);
487-
return i2c_add_adapter(&ali15x3_adapter);
489+
ret = i2c_add_adapter(&ali15x3_adapter);
490+
if (ret)
491+
goto release_region;
492+
493+
return 0;
494+
495+
release_region:
496+
release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE);
497+
return ret;
488498
}
489499

490500
static void ali15x3_remove(struct pci_dev *dev)

0 commit comments

Comments
 (0)