From patchwork Sun Apr 30 15:55:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9706133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 82DC5602B5 for ; Sun, 30 Apr 2017 15:55:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E39B2684F for ; Sun, 30 Apr 2017 15:55:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4085326C9B; Sun, 30 Apr 2017 15:55:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 116E92684F for ; Sun, 30 Apr 2017 15:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756991AbdD3Pzl (ORCPT ); Sun, 30 Apr 2017 11:55:41 -0400 Received: from mout.web.de ([212.227.15.14]:64245 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756985AbdD3Pzj (ORCPT ); Sun, 30 Apr 2017 11:55:39 -0400 Received: from [192.168.1.2] ([78.49.149.53]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MhlP1-1dQfZ62aO3-00Mprq; Sun, 30 Apr 2017 17:55:36 +0200 To: linux-fsdevel@vger.kernel.org, Miklos Szeredi Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] fuse: Use kmalloc_array() in three functions Message-ID: <2e6f0cd2-2a24-2d1e-9301-7e5238372306@users.sourceforge.net> Date: Sun, 30 Apr 2017 17:55:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:luZFokP89AHbo4ay4J0G+rkSS9fN0itT1M56oLLeKSqBGHmtsS3 pDucIchWy33KFazGkaw02rQwcRFnrV7LWEf/p4H/E8KW+Pe2wzIbyD8EYLjgQcW55iWh+BV 1O3oKkM//yQnS0RrHiiJwFuZD8s48wx24ypvnHtUrgKnlMKG6Awcpo1ELFJCm3wLUOSOwQH OQpZy4Tp2ZY5gU+K+UAKA== X-UI-Out-Filterresults: notjunk:1; V01:K0:Oun8vdQ3ur8=:swu+nCs65EP0QmYXM1VBnY iP9Nrgbc2qXyODxmQNsp/rw7+0eGnflhwn/swpzGXEDNieBxCraB3KVVALSVjQ9DP1sdDyLwp kU1dWcyJBlm33F4xXfkIe+Zjp4CDJW0zwVDyVaySUr8MqXY0lG4HArqwe6FKGZ60TYIdQ+/7H pHzNQYgBQ0UjO3JGWS+ZN54DBhx2kzRt/B569vQs8i0E+4y/EVPcr0zVtdQhcmxCkJOCxxW4Z T3Nxy4UrR5VQWJN2so6R7mHVqRqXPO/9aIT2ZhMH41VxNXMe8ESaKzZCduF2RG+Pra0qujGAl qSXkWOW3QQBzsBOsqP4t/0xz1W4uTO4aO4DwBGUXfBxRkL+B9uDhMSiSoyI54xRCBET0q7ZGg dNfudWF0zg4nfnObnUYh3KhF4kAepKO83Y2wVlEwN9wJI2eabKaHiZOKGYxao8J/i8ooLXcd5 8i5Uqft6D6tSg6aoUMDkHFa71qPxCnai2aX9ebI5VbuqPbmOrRYxrMb02AOHLesRZlOdwHkKi kGEGLD066bSdwPr9e1vbIPZT2XoS91tb6CV0ensCCm7R8Z8boSw/b5cpGw9ghSb5OK7t+08Fq g4gpuPKTaIP5YOh8yeOlRTe8KOOScBjmiiUAedHO7CKpzL/T30IUwCWBGko2H8P02HqdK81z6 qdjjieChr7F92rTirWa9i7xdI3CTdmJRClbMQTE0WvzasDbjhQtvLF/h7RnWVa8r0W84UNm+h OCOlNVH2O/seYHdoqeMo+uFZSlmz5yNYS2iqohfF9OC+0thmZD7HvgPeMOdkmEWWJHAageFlV iJEUIeK Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 30 Apr 2017 17:45:19 +0200 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of data types by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- fs/fuse/dev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index c16d00e53264..685dd467c5f7 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -64,9 +64,9 @@ static struct fuse_req *__fuse_request_alloc(unsigned npages, gfp_t flags) pages = req->inline_pages; page_descs = req->inline_page_descs; } else { - pages = kmalloc(sizeof(struct page *) * npages, flags); - page_descs = kmalloc(sizeof(struct fuse_page_desc) * - npages, flags); + pages = kmalloc_array(npages, sizeof(*pages), flags); + page_descs = kmalloc_array(npages, sizeof(*page_descs), + flags); } if (!pages || !page_descs) { @@ -1357,7 +1357,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos, if (!fud) return -EPERM; - bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL); + bufs = kmalloc_array(pipe->buffers, sizeof(*bufs), GFP_KERNEL); if (!bufs) return -ENOMEM; @@ -1941,7 +1941,7 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, if (!fud) return -EPERM; - bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL); + bufs = kmalloc_array(pipe->buffers, sizeof(*bufs), GFP_KERNEL); if (!bufs) return -ENOMEM;