From nobody Sun Dec 14 01:57:45 2025 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 7202C481B6; Sat, 26 Apr 2025 06:08:02 +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=1745647682; cv=none; b=iGCswgw/eYhkV/ERVbMvqjMlM2XAZOn2OSrn2R0GwuBidJZSPkpJuHUa3uyKCzFofPapcp4XCaZv0OBxstvSsKfjU1ov4SShJ8OeihgGeLWEjCV9zik6sBgajRQTA5w+29JofN9MbBWGXWKrl1dcFPN93M7LdpBRro6Exx35r6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745647682; c=relaxed/simple; bh=os9zCEaCkCpN9yXXWUgkC0GWbB1/AbE3Rvj9+ZNhXGI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=BlbDlW2gUgIfzmwfz0iiTXqhPNes7EwOvD+Dwb693IGCPZnuo+BZnIRCktNI4LtELCVgW15i6NI9aBy37qZQra9B0PykZAmaI3aB/kq3olg4td1/KjM4FWM2X9K2h0u3jgBG1ltGgRdB9d51GnA7mGfEIlAMTC2Y2uBm7RxE34g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UIlbAqfG; 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="UIlbAqfG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CE53C4CEE2; Sat, 26 Apr 2025 06:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745647682; bh=os9zCEaCkCpN9yXXWUgkC0GWbB1/AbE3Rvj9+ZNhXGI=; h=From:To:Cc:Subject:Date:From; b=UIlbAqfG2NuOCQ/4keS3DbgJERxOBXmliKxntsJBaPF/5eNTsofy3oW5+7NXJjb+4 0laX6LRwC3uecmAy8ciMSQK31GKJYoK+pAwyEwHXx3TlS1sx/trJiQGiyi4Of2n6jX KjvGAWz7LdKQ32Y2jHAwyRa4dSvYQBuLqnL4d6z3woAOSlHPMD64c1Kc9fyH4xc8u3 B6wBxyR89o8gGyYCdi/VUp1TdQ61s0GJqZWqO1IjE3WMY50Y0ZsQb2ZnldTJUL4Xzo FqXv/uGXKJa3IWQBS1y4JIXP8GfsdurNi/zuVq+G5vugSTIT0dvDvxAf0DDut9UVBi PMjzcn1jrtZrA== From: Kees Cook To: Tariq Toukan Cc: Kees Cook , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] net/mlx4_core: Adjust allocation type for buddy->bits Date: Fri, 25 Apr 2025 23:07:58 -0700 Message-Id: <20250426060757.work.865-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1623; i=kees@kernel.org; h=from:subject:message-id; bh=os9zCEaCkCpN9yXXWUgkC0GWbB1/AbE3Rvj9+ZNhXGI=; b=owGbwMvMwCVmps19z/KJym7G02pJDBk8FXadu/kd/v0yzbedkP1WVK3iclrQxfZHV4xVjhk21 z9fO21PRykLgxgXg6yYIkuQnXuci8fb9nD3uYowc1iZQIYwcHEKwERsVjAybO//pap2s1fl05Ej cucnKXAavS95XxkztYDB6a7sJY8FbQz/TJyzY//L9Cp3buKUniWosm7JpmMOV5cpPfE/pCa9R7q NGwA= X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation for making the kmalloc family of allocators type aware, we need to make sure that the returned type from the allocation matches the type of the variable being assigned. (Before, the allocator would always return "void *", which can be implicitly cast to any pointer type.) The assigned type is "unsigned long **", but the returned type will be "long **". These are the same size allocation (pointer size) but the types do not match. Adjust the allocation type to match the assignment. Signed-off-by: Kees Cook Reviewed-by: Simon Horman Reviewed-by: Tariq Toukan --- Cc: Tariq Toukan Cc: Andrew Lunn Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Cc: --- drivers/net/ethernet/mellanox/mlx4/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet= /mellanox/mlx4/mr.c index d7444782bfdd..698a5d1f0d7e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -106,7 +106,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, in= t max_order) buddy->max_order =3D max_order; spin_lock_init(&buddy->lock); =20 - buddy->bits =3D kcalloc(buddy->max_order + 1, sizeof(long *), + buddy->bits =3D kcalloc(buddy->max_order + 1, sizeof(*buddy->bits), GFP_KERNEL); buddy->num_free =3D kcalloc(buddy->max_order + 1, sizeof(*buddy->num_free= ), GFP_KERNEL); --=20 2.34.1