From mboxrd@z Thu Jan 1 00:00:00 1970 From: Denis Bolotin Subject: [PATCH net 1/2] qed: Fix bitmap_weight() check Date: Mon, 19 Nov 2018 16:28:30 +0200 Message-ID: <20181119142831.8035-2-denis.bolotin@cavium.com> References: <20181119142831.8035-1-denis.bolotin@cavium.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , Denis Bolotin , Michal Kalderon To: , Return-path: Received: from mail-eopbgr770041.outbound.protection.outlook.com ([40.107.77.41]:20553 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726235AbeKTAwo (ORCPT ); Mon, 19 Nov 2018 19:52:44 -0500 In-Reply-To: <20181119142831.8035-1-denis.bolotin@cavium.com> Sender: netdev-owner@vger.kernel.org List-ID: Fix the condition which verifies that only one flag is set. The API bitmap_weight() should receive size in bits instead of bytes. Fixes: b5a9ee7cf3be ("qed: Revise QM cofiguration") Signed-off-by: Denis Bolotin Signed-off-by: Michal Kalderon --- drivers/net/ethernet/qlogic/qed/qed_dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c index cff1410..9b41e4b 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c @@ -485,8 +485,11 @@ static u16 *qed_init_qm_get_idx_from_flags(struct qed_hwfn *p_hwfn, struct qed_qm_info *qm_info = &p_hwfn->qm_info; /* Can't have multiple flags set here */ - if (bitmap_weight((unsigned long *)&pq_flags, sizeof(pq_flags)) > 1) + if (bitmap_weight((unsigned long *)&pq_flags, + sizeof(pq_flags) * BITS_PER_BYTE) > 1) { + DP_ERR(p_hwfn, "requested multiple pq flags 0x%x\n", pq_flags); goto err; + } switch (pq_flags) { case PQ_FLAGS_RLS: -- 1.8.3.1