From mboxrd@z Thu Jan 1 00:00:00 1970 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 19DCD355808; Tue, 16 Dec 2025 12:14:04 +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=1765887248; cv=none; b=st1Jf4rhexlShQ9nUjzrn30Czk6MNiRggMtgShjnVsdaXEtnIJH35Bw9GMJ8CsctVyoArpbPmN11augNEhFd5DLNqutfNN4dm61OCBPturHm4mgeZAwWQ+pZeWDvlijrHijOWqJmFs7rxBu9+y5+gE8tMNnKhN8IMmd2otA5cWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765887248; c=relaxed/simple; bh=NkWrp3dwbInZjQkaYqzfPACqIQgDYIXOFkm3IBONuVo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y7tY4EOtDzaHdwcNOPtMWIVSqYvgofMjakIXfEYMNGrQ2xgktYTjnn8njeqf13BUdlFboauMYAI3ewNbfY4lwEMMniBmil46OJ8O4l6LAUof3XKdbYJitUjGiDU7+4F8O08tlJ9xKSikvU4i19RDbx0zjfNfzUUI8nyPYovSzQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wtoPgxSB; 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="wtoPgxSB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA27AC4CEF1; Tue, 16 Dec 2025 12:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765887244; bh=NkWrp3dwbInZjQkaYqzfPACqIQgDYIXOFkm3IBONuVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wtoPgxSB5NjLtCt3z2+qV78njr08+c02EGWnjBBKhUsyLhnaJ24pBJZts+pFbqAHt x0S1mXOKSzHDg6crA3dP/rZULUhCB6tlTXnpBRuA+4dgWFLRt69x1IEPlSYAGlEnEx sqSbfrRtZmkUPx6QctewYKBThYCDR2yW9nm6FFiw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haotian Zhang , Miquel Raynal , Sasha Levin Subject: [PATCH 6.18 138/614] mtd: rawnand: lpc32xx_slc: fix GPIO descriptor leak on probe error and remove Date: Tue, 16 Dec 2025 12:08:25 +0100 Message-ID: <20251216111406.333632669@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251216111401.280873349@linuxfoundation.org> References: <20251216111401.280873349@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haotian Zhang [ Upstream commit cdf44f1add4ec9ee80569d5a43e6e9bba0d74c7a ] The driver calls gpiod_get_optional() in the probe function but never calls gpiod_put() in the remove function or in the probe error path. This leads to a GPIO descriptor resource leak. The lpc32xx_mlc.c driver in the same directory handles this correctly by calling gpiod_put() on both paths. Add gpiod_put() in the remove function and in the probe error path to fix the resource leak. Fixes: 6b923db2867c ("mtd: rawnand: lpc32xx_slc: switch to using gpiod API") Signed-off-by: Haotian Zhang Signed-off-by: Miquel Raynal Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/lpc32xx_slc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c index b54d76547ffb2..fea3705a21386 100644 --- a/drivers/mtd/nand/raw/lpc32xx_slc.c +++ b/drivers/mtd/nand/raw/lpc32xx_slc.c @@ -937,6 +937,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) dma_release_channel(host->dma_chan); enable_wp: lpc32xx_wp_enable(host); + gpiod_put(host->wp_gpio); return res; } @@ -962,6 +963,7 @@ static void lpc32xx_nand_remove(struct platform_device *pdev) writel(tmp, SLC_CTRL(host->io_base)); lpc32xx_wp_enable(host); + gpiod_put(host->wp_gpio); } static int lpc32xx_nand_resume(struct platform_device *pdev) -- 2.51.0