Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp790146imm; Fri, 15 Jun 2018 06:22:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIN69pNeoHXBl5MIATMiZcotqBJE4RvfTSul+okzNH9X/LX/GOHMmK9M0FwVGtsOqRpVnmJ X-Received: by 2002:a63:6d41:: with SMTP id i62-v6mr1580929pgc.286.1529068938505; Fri, 15 Jun 2018 06:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529068938; cv=none; d=google.com; s=arc-20160816; b=kJSsgXGauIEOAM5gxTHfzEeXeCyJmu7gIgKPh8qAcu+FUqhqt5MUi/WtGR5fLBIAzl DvEQHTq3PUvX75Z11vq1gK3eKjz27AjN3EiPgo9uhE9QffRMqzcJRWnTJI72DvXMUN9L f4IetX+tTMHxSLEzdvzMOdaDGkQS3X8pwjysKsY1oNkDpnFNt0ok+e9bLEkcXuL/WcLy BfNI0QiJG7bP2/ZMREYmjxC+RKtb7TneummZ7c1fga5xSFgW4c2oZOaHt3996R3MwPhw jBrgp98X97F+UwPdf0lPUStf6pmF9NNF2xjf2WDKB/AeWKYAg3MI+wtzefxW/xRiMZV9 ti+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=dnj20m1C4+WyobIeA4XXiHkk06Jq4O9ea5u8COe8u44=; b=NqZ6kOByWxAc5XdfqSgf/WEDLx1J2OaS7FdzCQqFSGmNdwz0uq68TIDD5SnFJJYu1u EYz0UDILNHrD4tNhTfTFQftRmkSTGyk+KmADxEfFKpN++TOEZIpBPdgaflS5AD+xPFbT nK8Z2ysVqULmnJ5vIrRU6EZ0QT8Oni6jrQkAWLtH5TrphaLUid5CrxoIDGaM+nzwQSW0 lj5HEHfm98BzpR2YAMQOfzhstUIO7yvUhmPItKu0FzSrT3HS9wyAJfuom6bFHw1ByIBL an99tCgTTNxK31lMTvby8MiAJwNoP3siaF8fjPR+E5kdg98O1h7dxsCo6YnIT/LwdtM3 bvyQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g14-v6si7891766plq.41.2018.06.15.06.22.04; Fri, 15 Jun 2018 06:22:18 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965883AbeFONVL (ORCPT + 99 others); Fri, 15 Jun 2018 09:21:11 -0400 Received: from mga03.intel.com ([134.134.136.65]:30593 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965760AbeFONUZ (ORCPT ); Fri, 15 Jun 2018 09:20:25 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jun 2018 06:20:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,227,1526367600"; d="scan'208";a="50163145" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 15 Jun 2018 06:20:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7B8D24A2; Fri, 15 Jun 2018 16:20:18 +0300 (EEST) From: Andy Shevchenko To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , linux-raid@vger.kernel.org, Dmitry Torokhov , linux-input@vger.kernel.org, Andrew Morton , Yury Norov , linux-kernel@vger.kernel.org, mika.westerberg@linux.intel.com Cc: Andy Shevchenko Subject: [PATCH v2 5/5] Input: evdev - Switch to bitmap_zalloc() Date: Fri, 15 Jun 2018 16:20:17 +0300 Message-Id: <20180615132017.23889-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615132017.23889-1-andriy.shevchenko@linux.intel.com> References: <20180615132017.23889-1-andriy.shevchenko@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 *. Acked-by: Dmitry Torokhov Signed-off-by: Andy Shevchenko --- drivers/input/evdev.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index c81c79d01d93..370206f987f9 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -481,7 +481,7 @@ static int evdev_release(struct inode *inode, struct file *file) evdev_detach_client(evdev, client); for (i = 0; i < EV_CNT; ++i) - kfree(client->evmasks[i]); + bitmap_free(client->evmasks[i]); kvfree(client); @@ -925,17 +925,15 @@ static int evdev_handle_get_val(struct evdev_client *client, { int ret; unsigned long *mem; - size_t len; - len = BITS_TO_LONGS(maxbit) * sizeof(unsigned long); - mem = kmalloc(len, GFP_KERNEL); + mem = bitmap_alloc(maxbit, GFP_KERNEL); if (!mem) return -ENOMEM; spin_lock_irq(&dev->event_lock); spin_lock(&client->buffer_lock); - memcpy(mem, bits, len); + bitmap_copy(mem, bits, maxbit); spin_unlock(&dev->event_lock); @@ -947,7 +945,7 @@ static int evdev_handle_get_val(struct evdev_client *client, if (ret < 0) evdev_queue_syn_dropped(client); - kfree(mem); + bitmap_free(mem); return ret; } @@ -1003,13 +1001,13 @@ static int evdev_set_mask(struct evdev_client *client, if (!cnt) return 0; - mask = kcalloc(sizeof(unsigned long), BITS_TO_LONGS(cnt), GFP_KERNEL); + mask = bitmap_zalloc(cnt, GFP_KERNEL); if (!mask) return -ENOMEM; error = bits_from_user(mask, cnt - 1, codes_size, codes, compat); if (error < 0) { - kfree(mask); + bitmap_free(mask); return error; } @@ -1018,7 +1016,7 @@ static int evdev_set_mask(struct evdev_client *client, client->evmasks[type] = mask; spin_unlock_irqrestore(&client->buffer_lock, flags); - kfree(oldmask); + bitmap_free(oldmask); return 0; } -- 2.17.1