Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35B2E1CAA92; Wed, 19 Mar 2025 14:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742395267; cv=none; b=i4CVwkw1BA3BFQuN1sCDrrkX+zmI1QwgtMirx6BczGCaENCMY3x3f0LdhGraKF8mAfCvnHxFHy6MhUw9exvjcFvTtG9UfMbh9EshyzwiOD03uBenIIA2fDEA2NOeO4dKk4L5X8DkqOQA7UhZkROjZoXf1vkITpVG6Q0P1irkE+A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742395267; c=relaxed/simple; bh=7QUKmDtxghsdO6Rd1tZZoLXsOJTL7RU1GdRO+WE4XQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t/BEdwciS/2d0pUXyPLwa2Q9MASfkedbociqRpipBdH6Pgjq5N71aOI+RDn+7zQZCAJt58m+EZeRXRkf1sfFh6qdb/NgqqZrg/fef6i8tJXh7PKqNaxjlSGo0LKfGJC6h4dzcEJxsTaeaNN2cqfRlOAoAZzhn61uTBAAMAo6qr8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hshi/I+X; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hshi/I+X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0748AC4CEE4; Wed, 19 Mar 2025 14:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1742395267; bh=7QUKmDtxghsdO6Rd1tZZoLXsOJTL7RU1GdRO+WE4XQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hshi/I+XV7C0ko/dCKCcYfIzmfRMy8S0bb7vHp84f3xF9q/+lRMQIQvi2KkhHQg0d 0yVyFm99gdDRAfQISNZL8B10dMwvUyk1LB1bxx2MMhcjT/g97vhDS9s8Rt7x++ptws NWSZdAENulo61qxcC5w1LnVf9MRZj1ql2t1bXlxQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christophe JAILLET , Andi Shyti , Sasha Levin Subject: [PATCH 6.6 154/166] i2c: ali15x3: Fix an error handling path in ali15x3_probe() Date: Wed, 19 Mar 2025 07:32:05 -0700 Message-ID: <20250319143024.200621595@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250319143019.983527953@linuxfoundation.org> References: <20250319143019.983527953@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christophe JAILLET [ Upstream commit 6e55caaf30c88209d097e575a169b1dface1ab69 ] 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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Christophe JAILLET Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/9b2090cbcc02659f425188ea05f2e02745c4e67b.1741031878.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-ali15x3.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 0231c5be6354f..c3f76b13a76f5 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c @@ -474,6 +474,8 @@ MODULE_DEVICE_TABLE (pci, ali15x3_ids); static int ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id) { + int ret; + if (ali15x3_setup(dev)) { dev_err(&dev->dev, "ALI15X3 not detected, module not inserted.\n"); @@ -485,7 +487,15 @@ static int ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id) snprintf(ali15x3_adapter.name, sizeof(ali15x3_adapter.name), "SMBus ALI15X3 adapter at %04x", ali15x3_smba); - return i2c_add_adapter(&ali15x3_adapter); + ret = i2c_add_adapter(&ali15x3_adapter); + if (ret) + goto release_region; + + return 0; + +release_region: + release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE); + return ret; } static void ali15x3_remove(struct pci_dev *dev) -- 2.39.5