Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751691AbbBMDN6 (ORCPT ); Thu, 12 Feb 2015 22:13:58 -0500 Received: from lgeamrelo04.lge.com ([156.147.1.127]:63483 "EHLO lgeamrelo04.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbbBMDN5 (ORCPT ); Thu, 12 Feb 2015 22:13:57 -0500 X-Original-SENDERIP: 10.177.222.153 X-Original-MAILFROM: iamjoonsoo.kim@lge.com Date: Fri, 13 Feb 2015 12:16:14 +0900 From: Joonsoo Kim To: Stefan Strogin Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Marek Szyprowski , Michal Nazarewicz , aneesh.kumar@linux.vnet.ibm.com, Laurent Pinchart , Dmitry Safonov , Pintu Kumar , Weijie Yang , Laura Abbott , SeongJae Park , Hui Zhu , Minchan Kim , Dyasly Sergey , Vyacheslav Tyrtov , gregory.0xf0@gmail.com, sasha.levin@oracle.com, gioh.kim@lge.com, pavel@ucw.cz, stefan.strogin@gmail.com Subject: Re: [PATCH 1/4] mm: cma: add currently allocated CMA buffers list to debugfs Message-ID: <20150213031613.GJ6592@js1304-P5Q-DELUXE> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1067 Lines: 33 On Fri, Feb 13, 2015 at 01:15:41AM +0300, Stefan Strogin wrote: > static int cma_debugfs_get(void *data, u64 *val) > { > unsigned long *p = data; > @@ -125,6 +221,52 @@ static int cma_alloc_write(void *data, u64 val) > > DEFINE_SIMPLE_ATTRIBUTE(cma_alloc_fops, NULL, cma_alloc_write, "%llu\n"); > > +static int cma_buffers_read(struct file *file, char __user *userbuf, > + size_t count, loff_t *ppos) > +{ > + struct cma *cma = file->private_data; > + struct cma_buffer *cmabuf; > + struct stack_trace trace; > + char *buf; > + int ret, n = 0; > + > + if (*ppos < 0 || !count) > + return -EINVAL; > + > + buf = kmalloc(count, GFP_KERNEL); > + if (!buf) > + return -ENOMEM; Is count limited within proper size boundary for kmalloc()? If it can exceed page size, using vmalloc() is better than this. Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/