Received: by 10.213.65.68 with SMTP id h4csp672886imn; Fri, 6 Apr 2018 07:06:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+jNpGXwWfiugUZ7BRu8XpruXXGmEmNBOmp4/hdhdG+3PcByJeqsq+//q6eq1C880emtkLL X-Received: by 2002:a17:902:b7c2:: with SMTP id v2-v6mr22054519plz.190.1523023590315; Fri, 06 Apr 2018 07:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523023590; cv=none; d=google.com; s=arc-20160816; b=g3DKhLyjn/0wKEGd6H5XvA5M1T85+6HgiLKy6TCZ4jwP7VqAyHjewIxvryiZs1zBUn n4E1fOvHg7P80CGAkmj0lLVp5WgCEPdSEdcddsnSfwV07pwhJ4b8qw8WVBfdflp/Le8T FjzowO3yRUQ5d/loyjTqgqXXAeKEqcBfYYp5Fx0/ACPAjQprAntqM5IGCQSvBKarYAZr iA9+2EnV+jwqjCI+SexYpSBEeZmemrirgL0cRa+KEgS9LlBk09q8Y6m2lmk7o+kgJvMa fHtILKg9XeLa3+G+hI0eNL/YPimj4RUGS07KWv26jCoDVZQwIjKFhB/CyKlVhAtRyo8s 2OAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=EJhC/+LSyhWTRyvfYrvgMaAvNeMKRe/01kc4iy2ADS8=; b=f9q+oOh6fl7wFFvId/z4RhT2m5AumlpuXIbcIwn3iEAwYFUy98+9QzxKPjkN2X+nDr /5uCLDXzF/eL8/BI6KBaYUMu0DwFR5vDyeEpSGBEMY50tiY8w5h5aUCD/mNu7zF9kPHK 8cfevDYKRHwK3/rLT7tGVNtrF9OX9tMgxEcDfaH4szOoORtlzgtlLk0GbZ4v2CsGqbUB ik9aTCB2zbA9+frrlXEaTONUXkZaYi1MYUySJoTn8F29V24H42nFncQ4X8U2R+7QzcC7 BF6OLLAtPVJ/MoQlzzfiWZHsmTRAyUJcNG5bKVOtkbXIG+wKtm9SYTfoT1+VQ7IvdPRD 9KoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=a7BC1+/x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i21si8196039pfk.34.2018.04.06.07.06.16; Fri, 06 Apr 2018 07:06:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=a7BC1+/x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756549AbeDFOFH (ORCPT + 99 others); Fri, 6 Apr 2018 10:05:07 -0400 Received: from mail-cys01nam02on0078.outbound.protection.outlook.com ([104.47.37.78]:33687 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754509AbeDFOFE (ORCPT ); Fri, 6 Apr 2018 10:05:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=EJhC/+LSyhWTRyvfYrvgMaAvNeMKRe/01kc4iy2ADS8=; b=a7BC1+/x3VVZDiWgAcz9quH5y1X6NF3h4HHBMPm3v9rEeXompUpz7mE1OEWvdpceTzJ238g2J71tkCB198YRxLDnUTpIAFU8of4CzQ13eLjs2aXtC9YreiQuCB/0Av0fKfw5r3Zj6S3qLKmJXLFzjy5UqmuF6KKDpwFLnlgzAVg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Received: from localhost.localdomain.com (50.233.148.156) by MWHPR07MB3005.namprd07.prod.outlook.com (2603:10b6:300:e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Fri, 6 Apr 2018 14:05:00 +0000 From: Vadim Lomovtsev To: sgoutham@cavium.com, sunil.kovvuri@gmail.com, rric@kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dnelson@redhat.com, Vadim Lomovtsev Subject: [PATCH v3] net: thunderx: rework mac addresses list to u64 array Date: Fri, 6 Apr 2018 07:04:43 -0700 Message-Id: <20180406140443.15181-1-Vadim.Lomovtsev@caviumnetworks.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180406111425.14636-1-Vadim.Lomovtsev@caviumnetworks.com> References: <20180406111425.14636-1-Vadim.Lomovtsev@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: MWHPR2201CA0035.namprd22.prod.outlook.com (2603:10b6:301:28::48) To MWHPR07MB3005.namprd07.prod.outlook.com (2603:10b6:300:e0::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7a82f908-7ae7-48c5-d10d-08d59bc7631b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603328)(7153060)(7193020);SRVR:MWHPR07MB3005; X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB3005;3:+OSevCAPf1v5aBBfcnJCaUsc1IP+obVgx8nX7tPZIJjH9wJcSEvAlH7Y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ZHmK6qPrAyEAjOIX5gJhx72aXxIcMGJtBHmfcdfZuct+EvcXrVTIFuUoSGEECV/YR3jtGtYi3Jq6K09qQpQjr3QFbIcP2xJO8JGiWV4fqdVdrBHXPsOFyk5iQyeSdx2TXz0XTcAt1NUQuOC7FQ2yzbf6c1kT/DwqJH9Up7oViD6+rgMXYIp0jftYbDuq3X0S1f+p8I3t870AjO7G93dfzmXsc5acmkun9DymabvSLFUDrgrBS58AfV/nO3H6Hz/14JeB8rNBbW0cFcpPQk20ElmPkWjAxjaE0dusk3MK41NJvQJpXbCpmMJGI7SEbD3YEBl5Mx7EfaScczi0CB8iJyk3SqspiWKbeH+eo9hV0QELbw/h4xO/LSaiIj6t9usm5xMMbIh75qk410= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(277106579953875)(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(3002001)(3231221)(944501327)(52105095)(10201501046)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MWHPR07MB3005;BCL:0;PCL:0;RULEID:;SRVR:MWHPR07MB3005; X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB3005;4:S0hzEmSK8Z5494NmHhnl4A2bMOgvox/4C8tssECrl7cBj4GpdIRjutFfidGtKzHbtYBvwIJJf1/uyhUXSL9QI6BeuO9Nfj/VA4LlNUfu2HXMNcJbTsR6SySMOiQAkD7FG5IApDjQDz/jaAYIIxWnYpux2GKC5jjV87+10g3O1JtIBv0CoSJ9+hKW0xKJ0PkNo5sVzCwUpVSry2muaBPP793LsbFYg25k1N6wa6G54mkaBco6qcU7zHzbY4PShI94lboXF42AyBgQXHYeT0ejFPVr8KlaedvEkZ/l7LMR67cdNyCt7YGt/1zn/9lRVrBZgDih/jYjdZjnbSmqdSzgyJTC5WFNV1hKD8Qshk+ls7U= X-Forefront-PRVS: 0634F37BFF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(366004)(376002)(39380400002)(39860400002)(346002)(396003)(199004)(189003)(53416004)(47776003)(5660300001)(66066001)(97736004)(305945005)(7736002)(105586002)(48376002)(476003)(50466002)(2906002)(106356001)(69596002)(2616005)(3846002)(11346002)(446003)(1076002)(72206003)(51416003)(4326008)(956004)(6116002)(6512007)(52116002)(42882007)(6486002)(50226002)(6666003)(25786009)(486006)(26005)(59450400001)(478600001)(76176011)(316002)(16586007)(81166006)(81156014)(8936002)(107886003)(8676002)(39060400002)(16526019)(6506007)(53936002)(386003)(36756003)(68736007);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR07MB3005;H:localhost.localdomain.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR07MB3005;23:IYdoEngAgjBhyBCj87ZkfspiRHmO4VzbHUOoLP34g?= =?us-ascii?Q?MnaMCjhwRwxISEisJpyT0RnkkvAD6vFSRkTR3M63quISoFuRWCNRh0dCoiVZ?= =?us-ascii?Q?SgkQxUaprRmvPfWGbdjc/wT4v9XVrahpKS/q0O2AyrLYCjHZtzn4lfhz5Q8J?= =?us-ascii?Q?d61uQY3RWEZgx+kgUk+TdZmiXbbuKnpSrgB8WSB5N4p0fySgakX4wo2uzMvy?= =?us-ascii?Q?tB/bjeYFsnhuJoihhHLfWvjpctvXMzED7FRNi6RpUxeZ7Hm/ikHuI3Og9WaZ?= =?us-ascii?Q?5H82ruB5jk6B4qC6s6s8CWmdG6cqbpkJ1kyKrIncvp1y2+aWBFDQpR1OiCkC?= =?us-ascii?Q?GeafFGhMw8thO5drGqqCV9EguFl8ENcIx+ZcaF7SC7HpLuxhYIR7m1iyG2kX?= =?us-ascii?Q?wGC3yQiC9eE5N1daNZfOaW9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agnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB3005;7:WJ3/JNpn+gDN+KYyPHc2DnIK4B1ElQzuLJ5anZV+RJJ+qNp4xewB4oPKPTM/7KsTbNRDneUz1V7pOYzEVri0UXhip+0FDebBDTiKUoEuyTnfo8g2EgtqzDJPyDOj+Z8Ezz/grRGekkZNYjfBU8S4en+uu1TTSas83I7hdak37Fvp6uT0DZnOkgQfAm2wBHpnIOcBCbSQ6GIA9chdAuc2iALJwitHpsyL7AfYK1PiFPy/EmeHtOxd8RxR5mHQ/cxm X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2018 14:05:00.3701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a82f908-7ae7-48c5-d10d-08d59bc7631b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3005 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vadim Lomovtsev It is too expensive to pass u64 values via linked list, instead allocate array for them by overall number of mac addresses from netdev. This eventually removes multiple kmalloc() calls, aviod memory fragmentation and allow to put single null check on kmalloc return value in order to prevent a potential null pointer dereference. Addresses-Coverity-ID: 1467429 ("Dereference null return value") Fixes: 37c3347eb247 ("net: thunderx: add ndo_set_rx_mode callback implementation for VF") Reported-by: Dan Carpenter Signed-off-by: Vadim Lomovtsev --- Changes from v1 to v2: - C99 syntax: update xcast_addr_list struct field mc[0] -> mc[]; Changes from v2 to v3: - update commit description with 'Reported-by: Dan Carpenter'; - update size calculations for mc list to offsetof() call instead of explicit arithmetic; --- drivers/net/ethernet/cavium/thunder/nic.h | 7 +----- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 28 +++++++++--------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h index 5fc46c5a4f36..448d1fafc827 100644 --- a/drivers/net/ethernet/cavium/thunder/nic.h +++ b/drivers/net/ethernet/cavium/thunder/nic.h @@ -265,14 +265,9 @@ struct nicvf_drv_stats { struct cavium_ptp; -struct xcast_addr { - struct list_head list; - u64 addr; -}; - struct xcast_addr_list { - struct list_head list; int count; + u64 mc[]; }; struct nicvf_work { diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index 1e9a31fef729..7d9e58533a83 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -1929,7 +1929,7 @@ static void nicvf_set_rx_mode_task(struct work_struct *work_arg) work.work); struct nicvf *nic = container_of(vf_work, struct nicvf, rx_mode_work); union nic_mbx mbx = {}; - struct xcast_addr *xaddr, *next; + u8 idx = 0; if (!vf_work) return; @@ -1956,16 +1956,10 @@ static void nicvf_set_rx_mode_task(struct work_struct *work_arg) /* check if we have any specific MACs to be added to PF DMAC filter */ if (vf_work->mc) { /* now go through kernel list of MACs and add them one by one */ - list_for_each_entry_safe(xaddr, next, - &vf_work->mc->list, list) { + for (idx = 0; idx < vf_work->mc->count; idx++) { mbx.xcast.msg = NIC_MBOX_MSG_ADD_MCAST; - mbx.xcast.data.mac = xaddr->addr; + mbx.xcast.data.mac = vf_work->mc->mc[idx]; nicvf_send_msg_to_pf(nic, &mbx); - - /* after receiving ACK from PF release memory */ - list_del(&xaddr->list); - kfree(xaddr); - vf_work->mc->count--; } kfree(vf_work->mc); } @@ -1996,17 +1990,15 @@ static void nicvf_set_rx_mode(struct net_device *netdev) mode |= BGX_XCAST_MCAST_FILTER; /* here we need to copy mc addrs */ if (netdev_mc_count(netdev)) { - struct xcast_addr *xaddr; - - mc_list = kmalloc(sizeof(*mc_list), GFP_ATOMIC); - INIT_LIST_HEAD(&mc_list->list); + mc_list = kmalloc(offsetof(typeof(*mc_list), + mc[netdev_mc_count(netdev)]), + GFP_ATOMIC); + if (unlikely(!mc_list)) + return; + mc_list->count = 0; netdev_hw_addr_list_for_each(ha, &netdev->mc) { - xaddr = kmalloc(sizeof(*xaddr), - GFP_ATOMIC); - xaddr->addr = + mc_list->mc[mc_list->count] = ether_addr_to_u64(ha->addr); - list_add_tail(&xaddr->list, - &mc_list->list); mc_list->count++; } } -- 2.14.3