From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 DEA2F6FC5 for ; Sat, 21 Feb 2026 19:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771700718; cv=none; b=d3gH7yJ+ubh/rdoyEGLSVU5PmPjd6BzyxP8PKXm/3lPZ8tzWUcqJwG9vbsQeQciAz13TnV5X1QR2uaM4p5A3Yq2lgcxQdPvL0cqoKJ0HhC9CbZmFxQiQNBXoZ4UIslIq6iSYP12V9AR0wm30TeKu+SrqKtf68chUcSIVAfC5dSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771700718; c=relaxed/simple; bh=gKuYwENYrceJVeDntO1G4tFGAIwXGxYQRoFfN+PoFfw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jRVHdOCVEbwYHHfTyLTJ4onWGQYYHqIDAX+fRfB6NT2ntR5YYnIxgHGHuRS1tCvwigNf3DonswOfsNvsy2Jp4JWMMX0TlGHgbo0mzWqnH8LQkz+TlfaiT1ClA7VyiOkAkwtGjVzHcleZkIgdjN+Zj5rOIPoAPJCecmKUaMs9tlE= 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=EdeceEfM; arc=none smtp.client-ip=91.218.175.184 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="EdeceEfM" 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=1771700713; 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; bh=yLDQ4G+6GFW4iU0X3Mnjq0LBajt/MPm52sZH7eipsqY=; b=EdeceEfMPT/HNqUYPO72We4yfdggi2cTnMn+D9wm8fmzCRykKB02TV1XcWa1PEM8cZ0qGc /dQT1pGeA/XzITZ3FExKB89rkc5WM+q1A9D3ZEtpAi2UhafgqS30Eq2OetAXTFGFZxncvu mxyxvvVZ9zb4B4VlTCxK7hF1BaZCI0E= From: Thorsten Blum To: Lothar Rubusch , Herbert Xu , "David S. Miller" , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Linus Walleij , Ard Biesheuvel Cc: Thorsten Blum , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: atmel-sha204a - Fix potential UAF and memory leak in remove path Date: Sat, 21 Feb 2026 20:04:25 +0100 Message-ID: <20260221190424.85984-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Do not return early from atmel_sha204a_remove() when the device is busy. Instead, flush the I2C workqueue before teardown to prevent a potential UAF if a queued callback runs while the device is being removed. Also ensure sysfs entries are removed and ->hwrng.priv is freed, to prevent a memory leak during removal. Change the log level from emerg to warn because the system is still usable. Fixes: da001fb651b0 ("crypto: atmel-i2c - add support for SHA204A random number generator") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum --- Compile-tested only. --- drivers/crypto/atmel-sha204a.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c index 0fcf4a39de27..3afad915aae3 100644 --- a/drivers/crypto/atmel-sha204a.c +++ b/drivers/crypto/atmel-sha204a.c @@ -190,10 +190,10 @@ static void atmel_sha204a_remove(struct i2c_client *client) { struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client); - if (atomic_read(&i2c_priv->tfm_count)) { - dev_emerg(&client->dev, "Device is busy, will remove it anyhow\n"); - return; - } + if (atomic_read(&i2c_priv->tfm_count)) + dev_warn(&client->dev, "Device is busy, will remove it anyhow\n"); + + atmel_i2c_flush_queue(); sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups); -- Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4