Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp734400pxa; Thu, 27 Aug 2020 14:26:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwryjo80iftkderLdPYYSGex9AdR0/r8tVWdjMVLx+ihLl129rUrrEA2FKTTjeXXJ52bSN+ X-Received: by 2002:a50:8e11:: with SMTP id 17mr4651286edw.54.1598563609737; Thu, 27 Aug 2020 14:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598563609; cv=none; d=google.com; s=arc-20160816; b=EIrxQzE0xlgDvRLA3e+zNvLRdNO0L8xoEgtxl6wvLcXOUSBxmIDgejXXUjXXsrnFmx fY1KsT84XFN9EzjaZnRElK4L4DcfonBbC123U5L1rKMoN8tWD5y5j2hl7TRITUSF2kD9 JipeGcWunvxK4rf1m3eA7vWApGtQStyoaZbnNbtBCUvcn+7MdtQVVPXlmZm6V2TcW2PO 45U2KgTasVLQfIlJn0zN4FeYYB1dRkTL4uos/FCJcZIlHiGsMAPGwrZKm7hFzKrgwftC cYGfApHIaU5y6qbN/ec9QkgDLuTzvtHZVfRhAfoXDXK0em52bkgyiud1js6Tf5jgRn1q 7OUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Xbw0XMQIxQp3SFjhDOnpVzdj9Xjf2+nKdm+xYrgHGgo=; b=Xd/5MFnvWGPPw5kgBVDIb0h/CnMm0WkHmpjrY3B2Xr0V6ZTGH9FoVwypnX+t65oC6F EzDql/NvCKVvPN2UnpMnNDUnjG6dYblz8tqXYw6pT2umvr5wsdtkrkx8sXH/4cYO8s03 LItnX/RkH99S4X2lP82ChEKbAJHf+YK3EI7+GkeSrRem8yBFQq/BgoqVQqRyZnHHBXWd nWdF5/K2aLB6S92gZzSf5HHWl94hJGf1wZdfjlVUspmjIlsqbEl/F6AQyRTcGBSH0ohv XiVxMxOU2+T8ad/lpuMvYoLwBqxSuufSPWtKrrC+z7Fky52070mU/Y344dFK8cW/I46C 5KCg== 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 rh18si2230860ejb.166.2020.08.27.14.26.27; Thu, 27 Aug 2020 14:26:49 -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 S1726953AbgH0VZr (ORCPT + 99 others); Thu, 27 Aug 2020 17:25:47 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:40185 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbgH0VZp (ORCPT ); Thu, 27 Aug 2020 17:25:45 -0400 Received: by mail-lf1-f67.google.com with SMTP id j15so3706278lfg.7 for ; Thu, 27 Aug 2020 14:25:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xbw0XMQIxQp3SFjhDOnpVzdj9Xjf2+nKdm+xYrgHGgo=; b=FOwDL0dCf7vSSIb/HMot23++RxNuj/KHjI4dyn2gBFLf3heKR8ZBlfYcPQu7bXEUDM nGWESIdNuKfumWufCG08wdSGqT3E6iQ2qdgDVgQg+NQUNSQsclTddQbd2sk2YdENHOgf MCXymE+7PmURl+n/mKbW47Q9C125OokCaGslvVnonwJPKpy7kbGlj3cnsn6SE9mDSvrX 8NcLr770M7DeEc80YZyjiHFh/w2+DGx5YUvUMxBxLoXEA53Bx5loKOdyHxx9L1XyukSB WtsqEZnuICbNPciC7DxPyrwBK5mbGDQ4DGXKsSq/91H8pm4abh3eKYIZvG+qldFkWj+6 QlkA== X-Gm-Message-State: AOAM533ukd+QAPuUXFuOc5RMjvsny9mPHquTZ9eqaVtfqq0+6CYYQfSA qPg7MqrDugRQcBeH0x1evz84L6b1vlg= X-Received: by 2002:a05:6512:31c2:: with SMTP id j2mr10999275lfe.85.1598563543454; Thu, 27 Aug 2020 14:25:43 -0700 (PDT) Received: from localhost.localdomain ([213.87.147.111]) by smtp.googlemail.com with ESMTPSA id n29sm803427lfi.9.2020.08.27.14.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2020 14:25:42 -0700 (PDT) From: Denis Efremov To: Jan Kara Cc: Denis Efremov , linux-kernel@vger.kernel.org, Joe Perches Subject: [PATCH v2] udf: Use kvzalloc() in udf_sb_alloc_bitmap() Date: Fri, 28 Aug 2020 00:25:30 +0300 Message-Id: <20200827212530.48013-1-efremov@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827151923.40067-1-efremov@linux.com> References: <20200827151923.40067-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/udf/super.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 1c42f544096d..bdf51bea54f3 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1010,14 +1010,9 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index) 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 */ + size = struct_size(bitmap, s_block_bitmap, nr_groups); + bitmap = kvzalloc(size, GFP_KERNEL); if (!bitmap) return NULL; -- 2.26.2