From patchwork Sat Jun 19 13:47:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12332975 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CA5AC49361 for ; Sat, 19 Jun 2021 13:48:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E954D6108D for ; Sat, 19 Jun 2021 13:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234362AbhFSNuL (ORCPT ); Sat, 19 Jun 2021 09:50:11 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:54886 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233286AbhFSNuK (ORCPT ); Sat, 19 Jun 2021 09:50:10 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15JDfCXC018641; Sat, 19 Jun 2021 13:47:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=JSRIC/0gtdDjKMCTyPLvq6kWa6OGIKcWY9IcpSmOcNg=; b=f/UOJwgY1tRfgQNky2z9A33aL8CuPiS1Wwcq38nnVZQ/inV529STAh5DrYKqA81p6ydE WLXeWvMXbFTcFhSYsGWBweUWJzBEWwDwf2f3wLpI7RixrO+UOroKsn1o/NDyAXLQ8bj1 Y2htB5DnSGgEz959F3qtv85Evpls+rMTN5pgdWfmw/cjTIeBZ9v5mphvar6pYi7oWyQJ rlAzu3Qt7OO7p18erxMPIi2iasbYsVlOQYJuf5zDJGeKTFmkL75/iesOBPU2oG86dDfp iKjUbvV9GjGaB8BskyUv1q5uOjfrVzlXSxk2/HakhmK/BUHUiMcb0yuHNAQWL6RHxKHf 6Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3997600fu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Jun 2021 13:47:51 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 15JDdrp2185039; Sat, 19 Jun 2021 13:47:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3020.oracle.com with ESMTP id 3997wkdhpb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Jun 2021 13:47:50 +0000 Received: from userp3020.oracle.com (userp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 15JDlnih003808; Sat, 19 Jun 2021 13:47:49 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 3997wkdhnv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Jun 2021 13:47:49 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 15JDllvl019694; Sat, 19 Jun 2021 13:47:48 GMT Received: from mwanda (/102.222.70.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 19 Jun 2021 06:47:46 -0700 Date: Sat, 19 Jun 2021 16:47:38 +0300 From: Dan Carpenter To: Yisen Zhuang Cc: Salil Mehta , "David S. Miller" , Jakub Kicinski , Guangbin Huang , Yufeng Mo , Huazhong Tan , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH net-next 1/2] net: hns3: fix different snprintf() limit Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-ORIG-GUID: iuTRPcu7KJV0EAzXQ8yJFqSyCAC2JSpL X-Proofpoint-GUID: iuTRPcu7KJV0EAzXQ8yJFqSyCAC2JSpL Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- 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; From patchwork Sat Jun 19 13:49:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12332977 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3289BC49361 for ; Sat, 19 Jun 2021 13:49:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DD5260FEE for ; Sat, 19 Jun 2021 13:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234375AbhFSNv7 (ORCPT ); Sat, 19 Jun 2021 09:51:59 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:49518 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233286AbhFSNv5 (ORCPT ); Sat, 19 Jun 2021 09:51:57 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15JDfDDW004052; Sat, 19 Jun 2021 13:49:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=ntL+n6BZrznpoEt6sWjW1bFODyvAvXbvI8WeZoIgYHw=; b=dP7SonCoG/5XI0hmNTNxNyA7W3D2720fu7m5jd0DV3SQZF7pY0L92gTZDyMHAD4Fx4AM +Mq8yA95rkuvWD9agxchYMkIuGzXrWGlmC5SyA9fh29gfPHR8cU7U04Ecvgnridh8xtO 5/SE7j0y1HFwoae1RJxHkggkhQLujFmhQO4Wc122B+iRdhXtZ4xoD00K0+hrcoJqCozS mebOxsT4wFiK91bDvTn7JHmUkkzfR49P8kyf2qU52a8ozUlrbysVJ8Trdl82iG3vW9QF ukFcVrdgAKHNMA0UwcPpJ1TMyp6D4FfIgeiYsmN5izN9En/uGdaVM9EvThhYbmbLJ0Y4 Eg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39970bgge1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Jun 2021 13:49:30 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 15JDf1oU108790; Sat, 19 Jun 2021 13:49:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3030.oracle.com with ESMTP id 3995psqky8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Jun 2021 13:49:29 +0000 Received: from userp3030.oracle.com (userp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 15JDnS1R122763; Sat, 19 Jun 2021 13:49:28 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 3995psqkxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Jun 2021 13:49:28 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 15JDnRgU020572; Sat, 19 Jun 2021 13:49:27 GMT Received: from mwanda (/102.222.70.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 19 Jun 2021 06:49:27 -0700 Date: Sat, 19 Jun 2021 16:49:18 +0300 From: Dan Carpenter To: Yisen Zhuang Cc: Salil Mehta , "David S. Miller" , Jakub Kicinski , Huazhong Tan , Guangbin Huang , Yufeng Mo , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH net-next 2/2] net: hns3: fix a double shift bug Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email haha only kidding X-Proofpoint-GUID: L4mMCF0rsWLTYg3_DMyAlrDooLRklaHI X-Proofpoint-ORIG-GUID: L4mMCF0rsWLTYg3_DMyAlrDooLRklaHI Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_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;