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 500FD3B9DAE; Sat, 17 Oct 2026 17:13:28 +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=1792257209; cv=none; b=IwM2TUtNTzzcsOVHqckeV+dCv/wOwDBwhLZYb0zRZ9EC5D2RxfiXzr0WJhweQVxJzt+jx4RCW8Xs6WaZ16vqHxecU8dD6agKfIuV/G5no9Z3edGQsq+1mR61xaDIcisv3tRNudu8pFI5lU5bvkWBB29dDc1WBFKb5Wo6nRGLYvw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792257209; c=relaxed/simple; bh=XiL72hamsyqAIbFEv3AslMD+roNiLFwuCB77VFvZXoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DO37lJWZ/SP8qLg97ODTrB/AIz2YWE4bCBFmkUjm5J5DjtOags4OeIxtQtAV/7dEmUy7H3+uchd2qsBg+qOYZpMHnKMJFJS6J6rTVQ97Jp7W7z8uKC3qTLyl+8612PadKnrQnwi/yBOoqICGYvabNvSeNAb0YcxLsjVSy7RQlRM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cHUDAaYr; 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="cHUDAaYr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C9581F000C7; Sat, 17 Oct 2026 17:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792257208; bh=CPFOv5PQbXqX+GYPj97rFB5R22nYbB5vVljorFauaY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cHUDAaYrJfgM/ZzQ3NsfqeWutG2lCMeftdcMHnlzHlNMG1lzBhOsfWZNY+nmC3ZAP Wt6S3L0E+WvnJ/ojQMDGVPId3QQebH700bGrhFQCT3HgDVz6Fdh7WtSUI2tLlDJb0j Gq9Vo0igTwYHyUjOrBtWqbCAie4LNXXBzL4kSeyg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ridham Khurana , Bartosz Golaszewski Subject: [PATCH 6.6 0487/1674] gpio: xilinx: fix runtime PM leak on request error path Date: Sat, 17 Oct 2026 17:45:59 +0200 Message-ID: <20261017160443.616204523@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ridham Khurana commit ff82fc3a4a1d417dee1229681cc5285986edb1fa upstream. pm_runtime_get_sync() leaves the usage counter incremented even when it fails, and xgpio_request() returns the error without dropping it. gpiolib does not call ->free() when ->request() fails, so xgpio_free(), which holds the only matching pm_runtime_put(), never runs. The reference is leaked and the controller can no longer runtime-suspend, so its clock stays enabled. Switch to pm_runtime_resume_and_get(), which only increments the usage counter on success. Fixes: 26b04774621e ("gpio: gpio-xilinx: Add support for suspend and resume") Cc: stable@vger.kernel.org Signed-off-by: Ridham Khurana Link: https://patch.msgid.link/20260923113905.1409290-1-khurana.ridham222@gmail.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-xilinx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -293,14 +293,7 @@ static void xgpio_save_regs(struct xgpio static int xgpio_request(struct gpio_chip *chip, unsigned int offset) { - int ret; - - ret = pm_runtime_get_sync(chip->parent); - /* - * If the device is already active pm_runtime_get() will return 1 on - * success, but gpio_request still needs to return 0. - */ - return ret < 0 ? ret : 0; + return pm_runtime_resume_and_get(chip->parent); } static void xgpio_free(struct gpio_chip *chip, unsigned int offset)