Skip to content

Commit beb68cf

Browse files
tititiou36gregkh
authored andcommitted
i2c: ali1535: Fix an error handling path in ali1535_probe()
[ Upstream commit 9b5463f ] If i2c_add_adapter() fails, the request_region() call in ali1535_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/0daf63d7a2ce74c02e2664ba805bbfadab7d25e5.1741031571.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 10cbae8 commit beb68cf

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

drivers/i2c/busses/i2c-ali1535.c

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

491491
static int ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id)
492492
{
493+
int ret;
494+
493495
if (ali1535_setup(dev)) {
494496
dev_warn(&dev->dev,
495497
"ALI1535 not detected, module not inserted.\n");
@@ -501,7 +503,15 @@ static int ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id)
501503

502504
snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name),
503505
"SMBus ALI1535 adapter at %04x", ali1535_offset);
504-
return i2c_add_adapter(&ali1535_adapter);
506+
ret = i2c_add_adapter(&ali1535_adapter);
507+
if (ret)
508+
goto release_region;
509+
510+
return 0;
511+
512+
release_region:
513+
release_region(ali1535_smba, ALI1535_SMB_IOSIZE);
514+
return ret;
505515
}
506516

507517
static void ali1535_remove(struct pci_dev *dev)

0 commit comments

Comments
 (0)