From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A7D48389104; Tue, 13 Oct 2026 11:54:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791892498; cv=none; b=V3jKbKCHBqxA1Waa4t6J6OV1k84iWALbNaKrci/lEGm0NFdKzb7Rb8jdyfMXMwyqzl1IIwjPtZrR8bM7HgFpVVjATSrvJWjnRQNSsgFTr1/lrOa7et5nFc4B826HspBgiNeD7bxbuDoHe22SMeMYtl7Aj5te4Miyq2uY1giNlqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791892498; c=relaxed/simple; bh=sFvJ+l3342QOl2qao2Xjt2Y8H8LHz+toDVlrjH5av1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WqhNUu355/QmLymKLVZqL/zC60VNG1cIw8mJNyLdfDjus86jYahOB/IubRDmLpbjoszSG7ZI69KqP/sPGmPU8TXzTUtsKfKaX328/nTE93HULaYu3B4mIKOiWVyOfbVmglyYPjynEP6NvyU5w/WBC+vqvWFQxU4jpNhSbNTdkBs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aqJ0tpc5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aqJ0tpc5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B75BB1F000FF; Tue, 13 Oct 2026 11:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791892497; bh=bJqbHdYqR9VBgL31YZi+4UbvB36HcTq2E2yEB1n4X60=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aqJ0tpc5g9VQtxbyG7SXcQC8XQudy0pCJgMTspsPY/dzFlOrN136HsR6mVk1koXC6 WQFEZbIcb0ME7SXqs2v6dDc6gTm/CPXngXe6NwAcSLVSwTp4zM40ZumSSapFyh5KKi 2l8wftlk6k+2l698sluFw2k+//uHmRYbMyKBwZpA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Changyul Lee , Sang-Hoon Choi , Linus Walleij , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 7.2 193/281] gpio: exar: initialize the ID before registering its cleanup Date: Tue, 13 Oct 2026 13:38:29 +0200 Message-ID: <20261013112859.848469986@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112855.045212108@linuxfoundation.org> References: <20261013112855.045212108@linuxfoundation.org> User-Agent: quilt/0.69 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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sang-Hoon Choi [ Upstream commit 4d69e74034b208588636ecc177e0dd43a7696af3 ] devm_add_action_or_reset() invokes the cleanup action immediately when registering the action fails. gpio_exar_probe() currently stores the allocated ID in exar_gpio only after registering the action, so that failure makes exar_devm_ida_free() release ID 0. If the allocated ID is nonzero, this leaks that ID and can free ID 0 belonging to another device. Store the ID before registering the cleanup action so both the immediate failure path and normal device teardown release the correct allocation. Fixes: 5300ebb695fa ("gpio: exar: use devm action for freeing the IDA and drop remove()") Reported-by: Changyul Lee Assisted-by: LLM Signed-off-by: Sang-Hoon Choi Reviewed-by: Linus Walleij Link: https://patch.msgid.link/179070265834.12871.48183786512201899.idr-bug-79@gmail.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-exar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 9053662f18177..f629cc526f3ee 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -199,6 +199,7 @@ static int gpio_exar_probe(struct platform_device *pdev) index = ida_alloc(&ida_index, GFP_KERNEL); if (index < 0) return index; + exar_gpio->index = index; ret = devm_add_action_or_reset(dev, exar_devm_ida_free, exar_gpio); if (ret) @@ -214,7 +215,6 @@ static int gpio_exar_probe(struct platform_device *pdev) exar_gpio->gpio_chip.set = exar_set_value; exar_gpio->gpio_chip.base = -1; exar_gpio->gpio_chip.ngpio = ngpios; - exar_gpio->index = index; exar_gpio->first_pin = first_pin; ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio); -- 2.53.0