From nobody Tue Sep 9 21:28:46 2025 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) (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 1EA0D25C81B for ; Fri, 5 Sep 2025 10:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757068415; cv=none; b=Ikr7Wx3vfIeri/p0P/yC66TvvhJat6Btm8lLlmockOQcwr3FFg5SDmHLECJnDsC3xKjKl+rapGOZS/9GBF/2cjX6KVrZznuruBifwiLfcHdNPwCP4j+qWK98JUlJrxlIP3tdm4qvW/WLoS6Ajyt9bG17SjJ/ULPHZtQqc7eezVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757068415; c=relaxed/simple; bh=D7YdwhW1vYvMcOjQRLMZzGjxkzyVgthdK5KrId8iQBw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lO/g7SgEycKptGC26bGZA975yUFHJ87XChsDqoD4vlBXEM5Ew8Xfo4i/SkOuDEkR8Uc5ZkJAWroa3Jnx3PMsWPcPAks3VOt2OjFNTVIARsJH3wA0gAPSwtK390buArlaGEeli0vuaXLVL92jqkjqb7VBCcKknwGFGCf9IhI4/bQ= 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=k8IdPkbP; arc=none smtp.client-ip=95.215.58.181 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="k8IdPkbP" 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=1757068409; 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=93WUhwR/8sRIdEVQbXn2jRw424RE7/R4H5cbMH5sd+U=; b=k8IdPkbPuKwiN0WQtnVQSqlrWPc0gupOr48El0oaEMvMfD5qFg9dIpDTPvqBwdRXW+TaNf GhqrKAtq2q7IKzvF2uT0ArfsLLOpaA+DhFmUbMbF/YgFZGbOqmMBtcH1gZ1rvwcZH4Egfx XWGc0V4zIiMDg2MUXy+cy5CZ5kE8e2o= From: Thorsten Blum To: Arnd Bergmann , Greg Kroah-Hartman Cc: Thorsten Blum , linux-kernel@vger.kernel.org Subject: [PATCH] ibmasm: Replace kzalloc() + copy_from_user() with memdup_user_nul() Date: Fri, 5 Sep 2025 12:32:44 +0200 Message-ID: <20250905103247.423840-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace kzalloc() followed by copy_from_user() with memdup_user_nul() to improve and simplify remote_settings_file_write(). No functional changes intended. Signed-off-by: Thorsten Blum --- drivers/misc/ibmasm/ibmasmfs.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c index c44de892a61e..2d5c1df82732 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -525,15 +525,9 @@ static ssize_t remote_settings_file_write(struct file = *file, const char __user * if (*offset !=3D 0) return 0; =20 - buff =3D kzalloc (count + 1, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - - if (copy_from_user(buff, ubuff, count)) { - kfree(buff); - return -EFAULT; - } + buff =3D memdup_user_nul(ubuff, count); + if (IS_ERR(buff)) + return PTR_ERR(buff); =20 value =3D simple_strtoul(buff, NULL, 10); writel(value, address); --=20 2.51.0