From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 AC59D371861 for ; Wed, 11 Mar 2026 15:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773244688; cv=none; b=DPGx0w8pj+HlmNYgEdnTO3/Fi38GN2ImpnYqPkspYh1UUjrJF+VsRDgsPL81ubpzTC7gL3PrW8YPQnQ117l+DgV88XiwU+/jWumXgo4wKeJhv3xWD4IC739La/BiV2eVIU2klS3ewy5wffsiFTUx4VaLlTWB3xLGQnTaI5HAI8A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773244688; c=relaxed/simple; bh=z/oznr4rtFbg1KvAqQp9ghSB0UflG5RShs5mZ6Vs+GQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LdVX08HJlysAIIP98nREePqzV+xmAEXWFXLbkcEcNN95A2UHZi2afYwOqdhrjWlfkQGGb0ugkbHqzGhWiuAugBNv1mSY36DHyGYFqjZ1CPgCZy2tpMIt9m3doqWyzDR0khdxnTdNBR76dXAcdJ0EjoyfMWANouw3GBEl0JKlKqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HekBCL/4; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HekBCL/4" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1773244684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1AbKkPRYTP46mVFcNFbB21+SlkZKdM5Pe6Zl0TSZojs=; b=HekBCL/42ELYcZQnJPWdcGe07PHMv9hmsRPK7iJfAinq8Hej0KIIsdMcS5EcIixWyqGJiD c/Wc5glWKby019uFvQyOIrH5s3G+syasz7vPKrIPNsiVqXzT6i1Q4oyF/QiWpN6QFh5IVE c2TBzR99Rg9vsLYD2cr8pddjDTx1fl4= From: Thorsten Blum To: Haren Myneni , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Herbert Xu , "David S. Miller" , Ard Biesheuvel Cc: Thorsten Blum , stable@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] crypto: nx - fix context leak in nx842_crypto_free_ctx Date: Wed, 11 Mar 2026 16:56:49 +0100 Message-ID: <20260311155645.397083-6-thorsten.blum@linux.dev> In-Reply-To: <20260311155645.397083-4-thorsten.blum@linux.dev> References: <20260311155645.397083-4-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1476; i=thorsten.blum@linux.dev; h=from:subject; bh=z/oznr4rtFbg1KvAqQp9ghSB0UflG5RShs5mZ6Vs+GQ=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJkbJxx5M1lwitL7on7NzruqOz9N4zhXG7l/vWB1alT0k y7Jm4aSHaUsDGJcDLJiiiwPZv2Y4VtaU7nJJGInzBxWJpAhDFycAjCRnV8YGU4yfN5VrdtxovKM kCmnzIqIn4yXjNv3efC18v6TddK3WMTI8PyAf0c8R1pc8INv+/8q/VbMnrBL7EtVc0WMf4fujlo fRgA= X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Since the scomp conversion, nx842_crypto_alloc_ctx() allocates the context separately, but nx842_crypto_free_ctx() never releases it. Add the missing kfree(ctx) to nx842_crypto_free_ctx(), and reuse nx842_crypto_free_ctx() in the allocation error path. Fixes: 980b5705f4e7 ("crypto: nx - Migrate to scomp API") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum --- drivers/crypto/nx/nx-842.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c index 661568ce47f0..a61208cbcd27 100644 --- a/drivers/crypto/nx/nx-842.c +++ b/drivers/crypto/nx/nx-842.c @@ -115,10 +115,7 @@ void *nx842_crypto_alloc_ctx(struct nx842_driver *driver) ctx->sbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER); ctx->dbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER); if (!ctx->wmem || !ctx->sbounce || !ctx->dbounce) { - kfree(ctx->wmem); - free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); - free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); - kfree(ctx); + nx842_crypto_free_ctx(ctx); return ERR_PTR(-ENOMEM); } @@ -133,6 +130,7 @@ void nx842_crypto_free_ctx(void *p) kfree(ctx->wmem); free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); + kfree(ctx); } EXPORT_SYMBOL_GPL(nx842_crypto_free_ctx);