archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <>
To: Yisen Zhuang <>
Cc: Salil Mehta <>,
	"David S. Miller" <>,
	Jakub Kicinski <>,
	Huazhong Tan <>,
	Guangbin Huang <>,
	Yufeng Mo <>,,
Subject: [PATCH net-next 2/2] net: hns3: fix a double shift bug
Date: Sat, 19 Jun 2021 16:49:18 +0300	[thread overview]
Message-ID: <YM313rlzzvXqrSVQ@mwanda> (raw)
In-Reply-To: <YM31etbBvDRf+bgS@mwanda>

These flags are used to set and test bits like this:

	if (!test_bit(HCLGE_PTP_FLAG_TX_EN, &ptp->flags) ||

The issue is that test_bit() takes a bit number like 1, but we are
passing BIT(1) instead and it's testing BIT(BIT(1)).  This does not
cause a problem because it is always done consistently and the bit
values are very small.

Fixes: 0bf5eb788512 ("net: hns3: add support for PTP")
Signed-off-by: Dan Carpenter <>
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
index b3ca7afdaaa6..5a202b775471 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
@@ -43,9 +43,9 @@
 #define HCLGE_PTP_SEC_H_OFFSET		32u
-#define HCLGE_PTP_FLAG_EN		BIT(0)
+#define HCLGE_PTP_FLAG_EN		0
+#define HCLGE_PTP_FLAG_TX_EN		1
+#define HCLGE_PTP_FLAG_RX_EN		2
 struct hclge_ptp {
 	struct hclge_dev *hdev;

  reply	other threads:[~2021-06-19 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19 13:47 [PATCH net-next 1/2] net: hns3: fix different snprintf() limit Dan Carpenter
2021-06-19 13:49 ` Dan Carpenter [this message]
2021-06-21 19:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YM313rlzzvXqrSVQ@mwanda \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).