From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 92636353A9C; Thu, 2 Jul 2026 16:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783009388; cv=none; b=p5xI08AWTFauyW796ImtWrutO5eehqOgbzoFJv0RaQCnDq87HGo0ryJhbkipSczLEEbuhWvfavkhzZgGDOfCWFIpwRA5vgqzRlh+5R2nmu+zDka6+dHp63gIv9Lny2WElSkJQsDxGtKkiSAEWP4i6m6bj0v2xBCigmL6ydx4vjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783009388; c=relaxed/simple; bh=0mJjqpMacypBYt815wR6oVurmn7bxDaXcA/wNbpk+FI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dMkqxmy3kxNHghHGCgsVazfx8m9ucmj6EbptP316R37oj0AjsAhbBs66xUl4c1JENXZ0jWm9BHlhTm7ncbSF+ZHuwf90924wJFMszgWBfc5zXxaaQzLO2M6cKz47SVQ8t5lTj8W+r0bKfwaQv34clzCKH19E4DVIDGM+Ztv8+ek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KmhtCrW2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KmhtCrW2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30F4C1F00A3D; Thu, 2 Jul 2026 16:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783009384; bh=iL3RUtAsB17qbZYIDbj2NmqDW3iyGbZc8ZUNCEFopJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KmhtCrW2ZvgYuYdvfRz3kRxAryvMUEkAcMDMe/2b+WLpwBHSe8Lx2LFYrokj7aabh 5OnDXn36fiXY8PAjap5zHB7+yHNua4bEG4abbqx/dxDrWkT0bgRE5qmlHbw4ea4b3Y 7yR+qUTZZ9GrUSe2z6UBDB6jpZQ7Cf0UqYhh6lQw= 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 5.10 30/96] crypto: qat - Replace kzalloc() + copy_from_user() with memdup_user() Date: Thu, 2 Jul 2026 18:19:22 +0200 Message-ID: <20260702155109.619141018@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155108.949633242@linuxfoundation.org> References: <20260702155108.949633242@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thorsten Blum [ Upstream commit 1e26339703e2afd397037defa798682b2b93dcc0 ] Replace kzalloc() followed by copy_from_user() with memdup_user() to improve and simplify adf_ctl_alloc_resources(). memdup_user() returns either -ENOMEM or -EFAULT (instead of -EIO) if an error occurs. Remove the unnecessary device id initialization, since memdup_user() (like copy_from_user()) immediately overwrites it. No functional changes intended other than returning the more idiomatic error code -EFAULT. Signed-off-by: Thorsten Blum Signed-off-by: Herbert Xu Stable-dep-of: d237230728c5 ("crypto: qat - remove unused character device and IOCTLs") Signed-off-by: Sasha Levin --- drivers/crypto/qat/qat_common/adf_ctl_drv.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/qat/qat_common/adf_ctl_drv.c b/drivers/crypto/qat/qat_common/adf_ctl_drv.c index eb9b3be9d8ebed..cd2ab4e9c7c4e6 100644 --- a/drivers/crypto/qat/qat_common/adf_ctl_drv.c +++ b/drivers/crypto/qat/qat_common/adf_ctl_drv.c @@ -87,17 +87,10 @@ static int adf_ctl_alloc_resources(struct adf_user_cfg_ctl_data **ctl_data, { struct adf_user_cfg_ctl_data *cfg_data; - cfg_data = kzalloc(sizeof(*cfg_data), GFP_KERNEL); - if (!cfg_data) - return -ENOMEM; - - /* Initialize device id to NO DEVICE as 0 is a valid device id */ - cfg_data->device_id = ADF_CFG_NO_DEVICE; - - if (copy_from_user(cfg_data, (void __user *)arg, sizeof(*cfg_data))) { + cfg_data = memdup_user((void __user *)arg, sizeof(*cfg_data)); + if (IS_ERR(cfg_data)) { pr_err("QAT: failed to copy from user cfg_data.\n"); - kfree(cfg_data); - return -EIO; + return PTR_ERR(cfg_data); } *ctl_data = cfg_data; -- 2.53.0