Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp219812pxb; Tue, 31 Aug 2021 19:42:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzewawMsGv9CnXoOvHWhxCDt03kYTnPwWhkxbG2N158uVrFFlW7EdtttxYgxtCMXxvDkncG X-Received: by 2002:a05:6e02:d03:: with SMTP id g3mr23176052ilj.127.1630464134497; Tue, 31 Aug 2021 19:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630464134; cv=none; d=google.com; s=arc-20160816; b=UwS0AfgUZr03yQKHD0+N89B1hE9e96PEatcrzlKuZ5C5zAiShQGp1OuPJl8M/KfyhV y0DmlrVAuCzZKY3Mbu3LCSpADnWfrtvaksH7/DvLhCiWq2Y91tNiPtn9Zd4szLpvi1p1 6NbIzkwgT0LaG9QkEIIWq4v5HrpH3ffHI02RbhhxGxd3lnN4oBqWCG5Yj11wUDgOEVtE ATRH/OGm/MBP+9UmrfajMeroie/Lvx2WPr5D2NU0/9RkmJUVa1KR8C2ci2iqtY4SEacR aDTWjJoSt6OUp4g1Znb5SUTE350FuCx9HRk7LgJm5tBUxG5+Y4SM/QEZwafPHcMLdwMJ xU3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=E9cKF2YHbLjphDQCgh2eOWsRha2b9yjze6M9mmW+NIA=; b=miZEsFyVn8Setk5ROlcg5Dvk4koHSsK9J6Bm48BWNOnBywq5xgPTfI36sQbv0i5zpi aZwwG1OCgJpHHBd9HNTRZB4U/Mskzb6gh1a4uqfh1yw7QBDh+3hjiKPYA/IuOnySXTYt SfNnc8/zi8Yah+cO0tffN1UlI6Yl8pNI6hDVM5zMXwbVVzp8IKnqaR+p1zKBp4OpSDoW +IA6gf8N15Lu9Jf4aoDo3anKlVAbXXR81tM4BYq95VSJ00FZJUj2++GgqG24a7jWsJLN uZHUsIxfpz+vkmFKm3R/SQ4ABSIB9e2Pb2l5odhg427IOu4/ca0Naf3fkQIK/YG98Xwt Nh3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si18269786ilt.110.2021.08.31.19.41.52; Tue, 31 Aug 2021 19:42:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241660AbhIACl6 (ORCPT + 99 others); Tue, 31 Aug 2021 22:41:58 -0400 Received: from smtprelay0132.hostedemail.com ([216.40.44.132]:51820 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231613AbhIACl6 (ORCPT ); Tue, 31 Aug 2021 22:41:58 -0400 Received: from omf03.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 2F702100E7B45; Wed, 1 Sep 2021 02:41:01 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA id 6A68B13D97; Wed, 1 Sep 2021 02:41:00 +0000 (UTC) Message-ID: <5197939870d1867dd2131a8fdff8842b777c6016.camel@perches.com> Subject: Re: [PATCH 1/5] fs/ntfs3: Use kmalloc_array over kmalloc with multiply From: Joe Perches To: Kari Argillander , Konstantin Komarov , ntfs3@lists.linux.dev Cc: linux-kernel@vger.kernel.org Date: Tue, 31 Aug 2021 19:40:58 -0700 In-Reply-To: <20210831181505.1074767-2-kari.argillander@gmail.com> References: <20210831181505.1074767-1-kari.argillander@gmail.com> <20210831181505.1074767-2-kari.argillander@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=6.31 X-Stat-Signature: ocpfoi6u79nnsuqi3qfgc1bwhd7u4rmf X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 6A68B13D97 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18uSKCNe+O15Z6+tqeiXjSvmPXVWSJxc2w= X-HE-Tag: 1630464060-919141 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-08-31 at 21:15 +0300, Kari Argillander wrote: > If we do not use kmalloc_array we get checkpatch warning. It is also > little safer if something goes wrong with coding. [] > diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c [] > @@ -707,7 +707,7 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx, > ? u16 *ptr; > ? int new_slots = ALIGN(2 * nslots, 8); > ? > > - ptr = kmalloc(sizeof(u16) * new_slots, GFP_NOFS); > + ptr = kmalloc_array(new_slots, sizeof(u16), GFP_NOFS); > ? if (ptr) > ? memcpy(ptr, offs, sizeof(u16) * max_idx); This multiplication could also overflow. Maybe use krealloc?