i2c: ali1535: Fix an error handling path in ali1535_probe()

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: 1da177e4c3f4 ("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

authored by Christophe JAILLET and committed by Andi Shyti 9b5463f3 285df995

+11 -1
+11 -1
drivers/i2c/busses/i2c-ali1535.c
··· 485 485 486 486 static int ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id) 487 487 { 488 + int ret; 489 + 488 490 if (ali1535_setup(dev)) { 489 491 dev_warn(&dev->dev, 490 492 "ALI1535 not detected, module not inserted.\n"); ··· 498 496 499 497 snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name), 500 498 "SMBus ALI1535 adapter at %04x", ali1535_offset); 501 - return i2c_add_adapter(&ali1535_adapter); 499 + ret = i2c_add_adapter(&ali1535_adapter); 500 + if (ret) 501 + goto release_region; 502 + 503 + return 0; 504 + 505 + release_region: 506 + release_region(ali1535_smba, ALI1535_SMB_IOSIZE); 507 + return ret; 502 508 } 503 509 504 510 static void ali1535_remove(struct pci_dev *dev)