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 D510234751B; Tue, 16 Jun 2026 19:04:22 +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=1781636663; cv=none; b=mPN29xQJWedrG3Rotz4CnTorzbexJ+Uc9R79TnJE0GJ6JlTXlDk3mSUI4d2SbTlIiok5pXqZLiEgfKyMmrB5DJg+y9pch8NTPvyVYmnWTgNIqT0jlfUq69onI1GYR7VUxv0HaFQvSzWVixu/hb5i07l4JnaqNJXdIKjzL/UWV4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636663; c=relaxed/simple; bh=i/WbfDu6Ai5aFEY4bR5ngqaiHwdGOinDUZ4Msq3jSBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S/qhE0GnDx4KhrF+qxs0pB/S9M1zXcmFC9fO5ZIy+OUTsgFBh5lfJnyPUmy+1N32T/eZTCMmSsy3MQ7Gq2TZfFiLBIZJ+5q8ZQmKXEefIRFr8BPHgIpf1ob9ac4MAvwTVVSIRu+GR6MjEhLCZ6Ciwxi4gBoWJHlp7D1MN1Zw23k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NxX3JVr/; 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="NxX3JVr/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 899161F000E9; Tue, 16 Jun 2026 19:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781636662; bh=hePY3PxKq2x2dl9y27vOmAfuxiiW/cmx3l8/mFqXb1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NxX3JVr/mp1T8GQ2OpBCGmSQ81Un32S3Vp+Y6RT4ICIBy5AuIuB8GB7muKOzE8dz6 p5pKYsdQQYnbvrZmz+/nm50d0KKIT7GT/N+vkBCDtf6iBDr6ntqWIGr/gQC1kcNNaD eUVM9hga7du3wIA+GCnd9Td1B7o03duCkIDnHST0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christophe JAILLET , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 280/342] qed: Use the bitmap API to simplify some functions Date: Tue, 16 Jun 2026 20:29:36 +0530 Message-ID: <20260616145101.450653841@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@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: Christophe JAILLET [ Upstream commit 5e6c7ccd3ea4b25dd6b4b0363859913f315deacb ] 'cid_map' is a bitmap. So use 'bitmap_zalloc()' to simplify code, improve the semantic and avoid some open-coded arithmetic in allocator arguments. Also change the corresponding 'kfree()' into 'bitmap_free()' to keep consistency. Also change some 'memset()' into 'bitmap_zero()' to keep consistency. This is also much less verbose. Signed-off-by: Christophe JAILLET Signed-off-by: David S. Miller Stable-dep-of: 2bccfb8476ca ("qed: fix double free in qed_cxt_tables_alloc()") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qed/qed_cxt.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) --- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c +++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c @@ -1037,12 +1037,12 @@ static void qed_cid_map_free(struct qed_ u32 type, vf; for (type = 0; type < MAX_CONN_TYPES; type++) { - kfree(p_mngr->acquired[type].cid_map); + bitmap_free(p_mngr->acquired[type].cid_map); p_mngr->acquired[type].max_count = 0; p_mngr->acquired[type].start_cid = 0; for (vf = 0; vf < MAX_NUM_VFS; vf++) { - kfree(p_mngr->acquired_vf[type][vf].cid_map); + bitmap_free(p_mngr->acquired_vf[type][vf].cid_map); p_mngr->acquired_vf[type][vf].max_count = 0; p_mngr->acquired_vf[type][vf].start_cid = 0; } @@ -1055,15 +1055,10 @@ qed_cid_map_alloc_single(struct qed_hwfn u32 cid_start, u32 cid_count, struct qed_cid_acquired_map *p_map) { - u32 size; - if (!cid_count) return 0; - size = DIV_ROUND_UP(cid_count, - sizeof(unsigned long) * BITS_PER_BYTE) * - sizeof(unsigned long); - p_map->cid_map = kzalloc(size, GFP_KERNEL); + p_map->cid_map = bitmap_zalloc(cid_count, GFP_KERNEL); if (!p_map->cid_map) return -ENOMEM; @@ -1217,7 +1212,6 @@ void qed_cxt_mngr_setup(struct qed_hwfn struct qed_cid_acquired_map *p_map; struct qed_conn_type_cfg *p_cfg; int type; - u32 len; /* Reset acquired cids */ for (type = 0; type < MAX_CONN_TYPES; type++) { @@ -1226,11 +1220,7 @@ void qed_cxt_mngr_setup(struct qed_hwfn p_cfg = &p_mngr->conn_cfg[type]; if (p_cfg->cid_count) { p_map = &p_mngr->acquired[type]; - len = DIV_ROUND_UP(p_map->max_count, - sizeof(unsigned long) * - BITS_PER_BYTE) * - sizeof(unsigned long); - memset(p_map->cid_map, 0, len); + bitmap_zero(p_map->cid_map, p_map->max_count); } if (!p_cfg->cids_per_vf) @@ -1238,11 +1228,7 @@ void qed_cxt_mngr_setup(struct qed_hwfn for (vf = 0; vf < MAX_NUM_VFS; vf++) { p_map = &p_mngr->acquired_vf[type][vf]; - len = DIV_ROUND_UP(p_map->max_count, - sizeof(unsigned long) * - BITS_PER_BYTE) * - sizeof(unsigned long); - memset(p_map->cid_map, 0, len); + bitmap_zero(p_map->cid_map, p_map->max_count); } } }