* [PATCH net-next 1/2] net: hns3: fix different snprintf() limit
@ 2021-06-19 13:47 Dan Carpenter
2021-06-19 13:49 ` [PATCH net-next 2/2] net: hns3: fix a double shift bug Dan Carpenter
2021-06-21 19:20 ` [PATCH net-next 1/2] net: hns3: fix different snprintf() limit patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-06-19 13:47 UTC (permalink / raw)
To: Yisen Zhuang
Cc: Salil Mehta, David S. Miller, Jakub Kicinski, Guangbin Huang,
Yufeng Mo, Huazhong Tan, netdev, kernel-janitors
This patch doesn't affect runtime at all, it's just a correctness issue.
The ptp->info.name[] buffer has 16 characters but the snprintf() limit
was capped at 32 characters. Fortunately, HCLGE_DRIVER_NAME is "hclge"
which isn't close to 16 characters so we're fine.
Fixes: 0bf5eb788512 ("net: hns3: add support for PTP")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
index b3eb8f109dbb..3b1f84502e36 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
@@ -415,8 +415,6 @@ int hclge_ptp_get_ts_info(struct hnae3_handle *handle,
static int hclge_ptp_create_clock(struct hclge_dev *hdev)
{
-#define HCLGE_PTP_NAME_LEN 32
-
struct hclge_ptp *ptp;
ptp = devm_kzalloc(&hdev->pdev->dev, sizeof(*ptp), GFP_KERNEL);
@@ -424,7 +422,7 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev)
return -ENOMEM;
ptp->hdev = hdev;
- snprintf(ptp->info.name, HCLGE_PTP_NAME_LEN, "%s",
+ snprintf(ptp->info.name, sizeof(ptp->info.name), "%s",
HCLGE_DRIVER_NAME);
ptp->info.owner = THIS_MODULE;
ptp->info.max_adj = HCLGE_PTP_CYCLE_ADJ_MAX;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net-next 2/2] net: hns3: fix a double shift bug
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
2021-06-21 19:20 ` [PATCH net-next 1/2] net: hns3: fix different snprintf() limit patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-06-19 13:49 UTC (permalink / raw)
To: Yisen Zhuang
Cc: Salil Mehta, David S. Miller, Jakub Kicinski, Huazhong Tan,
Guangbin Huang, Yufeng Mo, netdev, kernel-janitors
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 <dan.carpenter@oracle.com>
---
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_SEC_L_MASK GENMASK(31, 0)
-#define HCLGE_PTP_FLAG_EN BIT(0)
-#define HCLGE_PTP_FLAG_TX_EN BIT(1)
-#define HCLGE_PTP_FLAG_RX_EN BIT(2)
+#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;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 1/2] net: hns3: fix different snprintf() limit
2021-06-19 13:47 [PATCH net-next 1/2] net: hns3: fix different snprintf() limit Dan Carpenter
2021-06-19 13:49 ` [PATCH net-next 2/2] net: hns3: fix a double shift bug Dan Carpenter
@ 2021-06-21 19:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-21 19:20 UTC (permalink / raw)
To: Dan Carpenter
Cc: yisen.zhuang, salil.mehta, davem, kuba, huangguangbin2, moyufeng,
tanhuazhong, netdev, kernel-janitors
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Sat, 19 Jun 2021 16:47:38 +0300 you wrote:
> This patch doesn't affect runtime at all, it's just a correctness issue.
>
> The ptp->info.name[] buffer has 16 characters but the snprintf() limit
> was capped at 32 characters. Fortunately, HCLGE_DRIVER_NAME is "hclge"
> which isn't close to 16 characters so we're fine.
>
> Fixes: 0bf5eb788512 ("net: hns3: add support for PTP")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: hns3: fix different snprintf() limit
https://git.kernel.org/netdev/net-next/c/faebad853455
- [net-next,2/2] net: hns3: fix a double shift bug
https://git.kernel.org/netdev/net-next/c/956c3ae411b2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-21 19:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19 13:47 [PATCH net-next 1/2] net: hns3: fix different snprintf() limit Dan Carpenter
2021-06-19 13:49 ` [PATCH net-next 2/2] net: hns3: fix a double shift bug Dan Carpenter
2021-06-21 19:20 ` [PATCH net-next 1/2] net: hns3: fix different snprintf() limit patchwork-bot+netdevbpf
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).