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 CF41D3955D4; Tue, 12 May 2026 17:49:58 +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=1778608198; cv=none; b=oy9TqZI41/8dHkVx6SApZLW3i8ayjNs6BUTXCp5SHvxt4U9mpsT8GptbSZM2vcB3cY1idw9iBxTDwYdT2klhewZ2dVdMLsU5oFYzYIyyGE0QLeycaKYsuMxXuWA9KoVWsrCKNS18ypZoPYXOAU7HoIPFCsM2c+XptUFR1P/fQBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778608198; c=relaxed/simple; bh=uKjMed4wp9CihK8TQOtiLYm7/mxwZz01sdZyh1Pnx6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xh1nUTHgWWmPKY9j6f36q9RAiUTWRgZueZBLFml6RSqybI9W+/Nlc1BmNxzj7BQ6dsVtHsUI3dbwQ9AgGLvd6hy4bw7yWGQA8j2pAv/KbjCzPlblMppB7LE3v1BKpm9ILJL5bHcxQnGUC68f4mzX7ZJPQodWyvBY3fJySSf6h8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yE0FAP6u; 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="yE0FAP6u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65D48C2BCF5; Tue, 12 May 2026 17:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778608198; bh=uKjMed4wp9CihK8TQOtiLYm7/mxwZz01sdZyh1Pnx6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yE0FAP6uY8VvqKDE6Fcn7WicwkT10kSbYcVI69GrM+dC+yfjA5oMIen+xw0Kzimj1 vZqdYz/zr6/3LrdZdjIMVQIFpeOJ+NtxWqq/cumgOy7SeF3kXwlIWVlycHOPF1BjKy Reb9RZVXDQJ+o8wF7odzcsEwh9O3N8ztBNBnvNFg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thorsten Blum , Herbert Xu , Sasha Levin Subject: [PATCH 6.12 191/206] crypto: nx - fix bounce buffer leaks in nx842_crypto_{alloc,free}_ctx Date: Tue, 12 May 2026 19:40:43 +0200 Message-ID: <20260512173936.913713646@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173932.810559588@linuxfoundation.org> References: <20260512173932.810559588@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thorsten Blum [ Upstream commit adb3faf2db1a66d0f015b44ac909a32dfc7f2f9c ] The bounce buffers are allocated with __get_free_pages() using BOUNCE_BUFFER_ORDER (order 2 = 4 pages), but both the allocation error path and nx842_crypto_free_ctx() release the buffers with free_page(). Use free_pages() with the matching order instead. Fixes: ed70b479c2c0 ("crypto: nx - add hardware 842 crypto comp alg") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/nx/nx-842.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/crypto/nx/nx-842.c +++ b/drivers/crypto/nx/nx-842.c @@ -116,8 +116,8 @@ void *nx842_crypto_alloc_ctx(struct nx84 ctx->dbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER); if (!ctx->wmem || !ctx->sbounce || !ctx->dbounce) { kfree(ctx->wmem); - free_page((unsigned long)ctx->sbounce); - free_page((unsigned long)ctx->dbounce); + free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); + free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); kfree(ctx); return ERR_PTR(-ENOMEM); } @@ -131,8 +131,8 @@ void nx842_crypto_free_ctx(void *p) struct nx842_crypto_ctx *ctx = p; kfree(ctx->wmem); - free_page((unsigned long)ctx->sbounce); - free_page((unsigned long)ctx->dbounce); + free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); + free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); } EXPORT_SYMBOL_GPL(nx842_crypto_free_ctx);