From patchwork Sun Dec 20 21:30:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 11984029 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 8FE81C4361B for ; Sun, 20 Dec 2020 21:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 545D222AAD for ; Sun, 20 Dec 2020 21:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbgLTVbS (ORCPT ); Sun, 20 Dec 2020 16:31:18 -0500 Received: from mga06.intel.com ([134.134.136.31]:14836 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbgLTVbS (ORCPT ); Sun, 20 Dec 2020 16:31:18 -0500 IronPort-SDR: qACv4YXbjqHpBPR5VM3loR6CHLf8E2EYYaD0MUG+48lZnUK5Ilm/NdxbAsnK8enbIqRmVCo+rO 8htSy5HV9XUQ== X-IronPort-AV: E=McAfee;i="6000,8403,9841"; a="237220766" X-IronPort-AV: E=Sophos;i="5.78,435,1599548400"; d="scan'208";a="237220766" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2020 13:29:31 -0800 IronPort-SDR: SaSo4Vuc49s2tlW12R2hTwf/0LomY+kj7N+XA5VFOVAGkR6jJ+WDFKzZdJ0GEBhk9kLi8XKba6 M8NQGueBPu/Q== X-IronPort-AV: E=Sophos;i="5.78,435,1599548400"; d="scan'208";a="560244545" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2020 13:29:30 -0800 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 8A80820204; Sun, 20 Dec 2020 23:29:28 +0200 (EET) Received: from sailus by punajuuri.localdomain with local (Exim 4.92) (envelope-from ) id 1kr6HM-0004Lc-8z; Sun, 20 Dec 2020 23:30:12 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Arnd Bergmann , Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab Subject: [PATCH 1/1] v4l: ioctl: Use kmalloc to allocate a small chunk of memory Date: Sun, 20 Dec 2020 23:30:12 +0200 Message-Id: <20201220213012.16671-1-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org kvmalloc() was used to release the temporary memory buffer that was used to contain both the IOCTL argument as well as a possible array argument that could have been large. Now that the two are separated, the IOCTL argument is known to be small in size. Use kmalloc to allocate it instead of kvmalloc. Similarly for releasing it. Suggested-by: Arnd Bergmann Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 9906b41004e9b..8d5d9c39c1622 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -3300,7 +3300,7 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, parg = sbuf; } else { /* too big to allocate from stack */ - mbuf = kvmalloc(ioc_size, GFP_KERNEL); + mbuf = kmalloc(ioc_size, GFP_KERNEL); if (NULL == mbuf) return -ENOMEM; parg = mbuf; @@ -3377,7 +3377,7 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, err = -EFAULT; out: kvfree(array_buf); - kvfree(mbuf); + kfree(mbuf); return err; }