From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 96E62C43381 for ; Mon, 4 Mar 2019 09:49:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68E3320836 for ; Mon, 4 Mar 2019 09:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbfCDJtA (ORCPT ); Mon, 4 Mar 2019 04:49:00 -0500 Received: from mga03.intel.com ([134.134.136.65]:21485 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbfCDJs7 (ORCPT ); Mon, 4 Mar 2019 04:48:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 01:48:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,439,1544515200"; d="scan'208";a="156581506" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 04 Mar 2019 01:48:58 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1853114E; Mon, 4 Mar 2019 11:48:56 +0200 (EET) From: Andy Shevchenko To: "David S. Miller" , netdev@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1] net-sysfs: Switch to bitmap_zalloc() Date: Mon, 4 Mar 2019 11:48:56 +0200 Message-Id: <20190304094856.58134-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *. Signed-off-by: Andy Shevchenko --- net/core/net-sysfs.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 7c5061123ead..76161503527b 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1336,8 +1336,7 @@ static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf) if (tc < 0) return -EINVAL; } - mask = kcalloc(BITS_TO_LONGS(dev->num_rx_queues), sizeof(long), - GFP_KERNEL); + mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL); if (!mask) return -ENOMEM; @@ -1366,7 +1365,7 @@ static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf) rcu_read_unlock(); len = bitmap_print_to_pagebuf(false, buf, mask, dev->num_rx_queues); - kfree(mask); + bitmap_free(mask); return len < PAGE_SIZE ? len : -EINVAL; } @@ -1382,8 +1381,7 @@ static ssize_t xps_rxqs_store(struct netdev_queue *queue, const char *buf, if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) return -EPERM; - mask = kcalloc(BITS_TO_LONGS(dev->num_rx_queues), sizeof(long), - GFP_KERNEL); + mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL); if (!mask) return -ENOMEM; @@ -1391,7 +1389,7 @@ static ssize_t xps_rxqs_store(struct netdev_queue *queue, const char *buf, err = bitmap_parse(buf, len, mask, dev->num_rx_queues); if (err) { - kfree(mask); + bitmap_free(mask); return err; } @@ -1399,7 +1397,7 @@ static ssize_t xps_rxqs_store(struct netdev_queue *queue, const char *buf, err = __netif_set_xps_queue(dev, mask, index, true); cpus_read_unlock(); - kfree(mask); + bitmap_free(mask); return err ? : len; } -- 2.20.1