Commit e7da65a4 authored by Dan Carpenter's avatar Dan Carpenter Committed by Zheng Zengkai
Browse files

net: hns3: fix different snprintf() limit

mainline inclusion
from mainline-master
commit faebad85
category: bugfix
bugzilla: 173966
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=faebad853455b7126450c1690f7c31e048213543



----------------------------------------------------------------------

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: 0bf5eb78 ("net: hns3: add support for PTP")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Reviewed-by: default avatarYongxin Li <liyongxin1@huawei.com>
Signed-off-by: default avatarJunxin Chen <chenjunxin1@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 6af72963
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -415,8 +415,6 @@ int hclge_ptp_get_ts_info(struct hnae3_handle *handle,


static int hclge_ptp_create_clock(struct hclge_dev *hdev)
static int hclge_ptp_create_clock(struct hclge_dev *hdev)
{
{
#define HCLGE_PTP_NAME_LEN	32

	struct hclge_ptp *ptp;
	struct hclge_ptp *ptp;


	ptp = devm_kzalloc(&hdev->pdev->dev, sizeof(*ptp), GFP_KERNEL);
	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;
		return -ENOMEM;


	ptp->hdev = hdev;
	ptp->hdev = hdev;
	snprintf(ptp->info.name, HCLGE_PTP_NAME_LEN, "%s",
	snprintf(ptp->info.name, sizeof(ptp->info.name), "%s",
		 HCLGE_DRIVER_NAME);
		 HCLGE_DRIVER_NAME);
	ptp->info.owner = THIS_MODULE;
	ptp->info.owner = THIS_MODULE;
	ptp->info.max_adj = HCLGE_PTP_CYCLE_ADJ_MAX;
	ptp->info.max_adj = HCLGE_PTP_CYCLE_ADJ_MAX;