From patchwork Thu Feb 27 08:23:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13993895 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 E41CD222574; Thu, 27 Feb 2025 08:24:13 +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=1740644654; cv=none; b=Jwr6J/cPmJ8plAQwnRpTJdEr5cWwZnXqdyTB7wF47oC1j2R9gphv8qsII6I10z1aziyILqLS570Fb71d7klV+y270REywhJY9xQ6P0R8KbLIX/IfgzmEO/ErqBdOhsPmDiQrpwXNb3SjV+ifEm9yTmZDzkvIbY7nbuzcaC/qiJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740644654; c=relaxed/simple; bh=0GwyfvPZJn3bBvAUj0HXY0BKgt3S89HLTvK3DfNGxcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FTuALEZjGabE2zIHdTw+V1OhjoXOu94MrCDbiAQgWi1ITAHrMboy1nPlMo+6myT9SSkXJnlwGYdBLvM46QHkpxjMheM4Jl+JRIt5It8YpaIwYn8rXA5/w+Rkpvwi8kfNKn5gjoh0AsLryM8o/TYSU4FEbiQtr63ilTcSirguh9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LcyepKSc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LcyepKSc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36156C4CEDD; Thu, 27 Feb 2025 08:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740644653; bh=0GwyfvPZJn3bBvAUj0HXY0BKgt3S89HLTvK3DfNGxcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LcyepKScv7I2bZPHYPxlwHmowLkAnN16Fj8SK3XrS5Me9awpoqjYNXNQDvx4wBFqV Gp0C2SaH3ekRyfWLDkYv2/iXzdBdlvGwn8o+HPlp0ijQJEMOx2/irJUWm/D4qtCR1B 1OkzG+8zABhUZtKroj1QL5IIkC84fYvx6cYoHBDBQFmwg7VV8tuIO7fGZQxg+z1Fwu Z2HUc6/m4on+Fn6aiA4ph1LWTSQ3zdz9SIzPOPUB4BJah48NLiThtOcz4haRc1KMjD rWi4BWIB1T/G7Iu8lLOWriq14JOh5SkNsAWoVLAeaUJ7B0mtDGRD1UN7kAqHbZgdTO TKuanVKvAbgww== From: Geliang Tang To: Eric Dumazet , Kuniyuki Iwashima , Paolo Abeni , Willem de Bruijn , "David S. Miller" , Jakub Kicinski , Simon Horman , Neal Cardwell , David Ahern , Matthieu Baerts , Mat Martineau , Marcelo Ricardo Leitner , Xin Long Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-sctp@vger.kernel.org Subject: [PATCH net-next 4/4] net/tcp_ao: use sock_kmemdup for tcp_ao_key Date: Thu, 27 Feb 2025 16:23:26 +0800 Message-ID: <38054b456a54cc5c7628c81a42816a770f0bff27.1740643844.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Instead of using sock_kmalloc() to allocate a tcp_ao_key "new_key" and then immediately duplicate the input "key" to it in tcp_ao_copy_key(), the newly added sock_kmemdup() helper can be used to simplify the code. Signed-off-by: Geliang Tang --- net/ipv4/tcp_ao.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c index bbb8d5f0eae7..d21412d469cc 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -246,12 +246,11 @@ static struct tcp_ao_key *tcp_ao_copy_key(struct sock *sk, { struct tcp_ao_key *new_key; - new_key = sock_kmalloc(sk, tcp_ao_sizeof_key(key), + new_key = sock_kmemdup(sk, key, tcp_ao_sizeof_key(key), GFP_ATOMIC); if (!new_key) return NULL; - *new_key = *key; INIT_HLIST_NODE(&new_key->node); tcp_sigpool_get(new_key->tcp_sigpool_id); atomic64_set(&new_key->pkt_good, 0);