From nobody Thu Nov 28 20:27:30 2024 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 789001C6B5 for ; Sat, 28 Sep 2024 15:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727535697; cv=none; b=Ulri3CQPV9jmUGAJ0Gueto31skPkcu4HRYc+bbxCsQpp6jxwStulAI6YZekl23kQmmYKcIKqItZz2VjEVSLVpIopnxzGp9h9qGp8q5WLh37XNPsb29r+sVt6xWbkvC/9Zmc0QhdJ/W6G9rTeGXEskMye7MIO+eGHpDzBrX7J1k0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727535697; c=relaxed/simple; bh=hQbNGU+VoX7SrygvtUBPpfRaQb5XWKk/IVkjxCjnCZs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iYjwLaPzn9f2sg2eHs4nE+J9io58LMrreRCx+0oz0ECPd2OIo6pljG21/sBO0jiuDEZkKT22VjsuSWX0SJg/sopO7tPn6S/3cgoPIw8FAZxDehDql+6nA/ka1IVES2VvY/CQMc5eIXKy/9OiGslMlytAXqBPHjtqTIluJlfxSXQ= 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=NKpd00nq; arc=none smtp.client-ip=95.215.58.172 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="NKpd00nq" 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=1727535692; 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=FEgxMd7iJWObOMaqxmGr+avDbf/vb2+1l6khmidZT+U=; b=NKpd00nqs1RcAhOEZMMQPj3AmVzP32EtusjN2EIY/PIeoH3KZFk/40qoHv8YMC9D6TxmoR zBO2SNzlwISr8ZOzHtSQuetPlY2rS0QkkZc2xnyXzm/ywEK3BvLsM/B2pYZHra/qj0E0cp 8kMpUR3Y6iWMRcosJDohLcb0sdF+yrA= From: Thorsten Blum To: Namjae Jeon , Steve French , Sergey Senozhatsky , Tom Talpey Cc: Thorsten Blum , linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ksmbd: Use struct_size() to improve smb_direct_rdma_xmit() Date: Sat, 28 Sep 2024 17:00:30 +0200 Message-ID: <20240928150030.1217-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" Use struct_size() to calculate the number of bytes to allocate for a new message. Signed-off-by: Thorsten Blum --- fs/smb/server/transport_rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c index 44c87e300c16..17c76713c6d0 100644 --- a/fs/smb/server/transport_rdma.c +++ b/fs/smb/server/transport_rdma.c @@ -1405,8 +1405,8 @@ static int smb_direct_rdma_xmit(struct smb_direct_tra= nsport *t, /* build rdma_rw_ctx for each descriptor */ desc_buf =3D buf; for (i =3D 0; i < desc_num; i++) { - msg =3D kzalloc(offsetof(struct smb_direct_rdma_rw_msg, sg_list) + - sizeof(struct scatterlist) * SG_CHUNK_SIZE, GFP_KERNEL); + msg =3D kzalloc(struct_size(msg, sg_list, SG_CHUNK_SIZE), + GFP_KERNEL); if (!msg) { ret =3D -ENOMEM; goto out; --=20 2.46.1