Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1091121pxa; Fri, 28 Aug 2020 03:31:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiVl1w0PpJEUxPIcL46JHlcwFHQy13k/NqObp2P164NawWW/8PDsKDdV70ffxUtc2g3eqD X-Received: by 2002:a17:906:f886:: with SMTP id lg6mr1031210ejb.227.1598610664179; Fri, 28 Aug 2020 03:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598610664; cv=none; d=google.com; s=arc-20160816; b=CTQdIBw9ie4xEIWlReIUgYkK0o6Yw1kY2tb3w0oDimm7N7YJCWIAszoXXFUhEuK2UF FRBOMSahQ+yP7MJ8z/+SQp+DojVLBSlM76OqjToIWtMAxRmwHJxVVdAVK4O5ZFo75WC5 lE31DL/cuR/CKcmBL8SxilW1zgiFBPusNdeITQzQ9vvNTiD//469Fv3iOHtIsaZuJxG5 +pR5wfBwgsMm/FHb1PfpnyBXPK4UKDIA72wiB9zPqQr9ecegt6n3MZx+RIZTmqZTUcXT cB1Z3Ki2QKy7oJ38fyYDiuKJQ7TbmuUWN143ZJ1aRr2x+N2rexho6x+wrqsUQbsSYf3K 17tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nm65Gn5Xbluu1i1H6voNLU5JEbTG8W0HvjFM0LhOAAA=; b=Uk2pBgZAuW/tspgNIffw53wsVk30/gcCskO7CSm33OQHDfYPoKGP2gnx/p1c5/mPCb hIFH582JerR5vkAXj74HOSF2JDTlHIpB3SDhWYDXnp3rM+IRpHRYInNgMpWeSzXnLa5X qjtWJdO8lx5JV+UiIg913/df/KqpIRX/tfnxN9eWGyZWHmJCc0MckoXpc5B8U57uel0N oSWG6QeU/7yXr6UnaQk3rFiQXca5dShiRQBq8kKSNQiucBBILwHm1ZUHvJeL/I0b4CGu yfboVUgFaVD50IDb65Bq/ylpWC4lo8j83EhKzpOmuvB/iT3Hwa3MVqxOoQc4mPzcshYw eYMA== 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 c5si308785edy.19.2020.08.28.03.30.41; Fri, 28 Aug 2020 03:31:04 -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 S1729101AbgH1K3s (ORCPT + 99 others); Fri, 28 Aug 2020 06:29:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:59844 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728972AbgH1K3h (ORCPT ); Fri, 28 Aug 2020 06:29:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C2727B1A0; Fri, 28 Aug 2020 10:30:08 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 74D101E12C0; Fri, 28 Aug 2020 12:29:35 +0200 (CEST) Date: Fri, 28 Aug 2020 12:29:35 +0200 From: Jan Kara To: "Gustavo A. R. Silva" Cc: Denis Efremov , Jan Kara , linux-kernel@vger.kernel.org, Joe Perches Subject: Re: [PATCH v3] udf: Use kvzalloc() in udf_sb_alloc_bitmap() Message-ID: <20200828102935.GC5098@quack2.suse.cz> References: <20200827151923.40067-1-efremov@linux.com> <20200827221652.64660-1-efremov@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 27-08-20 17:29:25, Gustavo A. R. Silva wrote: > > > On 8/27/20 17:16, Denis Efremov wrote: > > Use kvzalloc() in udf_sb_alloc_bitmap() instead of open-coding it. > > Size computation wrapped in struct_size() macro to prevent potential > > integer overflows. > > > > Signed-off-by: Denis Efremov > > Looks good. :) > > Reviewed-by: Gustavo A. R. Silva Thank you both. I've added the patch to my tree. Honza > > Thanks > -- > Gustavo > > > --- > > Changes in v2: > > - size computation wrapped in struct_size() > > Changes in v3: > > - int size dropped > > > > fs/udf/super.c | 14 +++----------- > > 1 file changed, 3 insertions(+), 11 deletions(-) > > > > diff --git a/fs/udf/super.c b/fs/udf/super.c > > index 1c42f544096d..d9eabbe368ff 100644 > > --- a/fs/udf/super.c > > +++ b/fs/udf/super.c > > @@ -1006,18 +1006,10 @@ int udf_compute_nr_groups(struct super_block *sb, u32 partition) > > static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index) > > { > > struct udf_bitmap *bitmap; > > - int nr_groups; > > - int size; > > - > > - nr_groups = udf_compute_nr_groups(sb, index); > > - size = sizeof(struct udf_bitmap) + > > - (sizeof(struct buffer_head *) * nr_groups); > > - > > - if (size <= PAGE_SIZE) > > - bitmap = kzalloc(size, GFP_KERNEL); > > - else > > - bitmap = vzalloc(size); /* TODO: get rid of vzalloc */ > > + int nr_groups = udf_compute_nr_groups(sb, index); > > > > + bitmap = kvzalloc(struct_size(bitmap, s_block_bitmap, nr_groups), > > + GFP_KERNEL); > > if (!bitmap) > > return NULL; > > > > > -- Jan Kara SUSE Labs, CR