From patchwork Fri Nov 1 00:46:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HIMANGI SARAOGI X-Patchwork-Id: 3122751 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B47DE9F3E3 for ; Fri, 1 Nov 2013 00:40:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7842520411 for ; Fri, 1 Nov 2013 00:46:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3F8B2044C for ; Fri, 1 Nov 2013 00:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754021Ab3KAAqI (ORCPT ); Thu, 31 Oct 2013 20:46:08 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:59398 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752508Ab3KAAqH (ORCPT ); Thu, 31 Oct 2013 20:46:07 -0400 Received: by mail-pa0-f44.google.com with SMTP id fb1so3300079pad.31 for ; Thu, 31 Oct 2013 17:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=vd7/1CbTw6/0mD7Y5S8RiEUOXSPUUF+VrlalJHGE2ec=; b=upOnTJ69HhuXm0gkVLmfX7sXKmIhcMaYLVC6v5jGc+MyJJ3NrThBW0x7+duBn3ttf7 Abu6pANWKYOqoVWvFIFwgopyzb+WrM3M0dmauB1g3N66ml9B9euUqIIiTG0KJ6kIM9/d eoYQxkvvbG+rUo5TKSrP3eAEVqntZMb6dhLzwx+IbnavElMs63+H3S63BtLnyw+BRNEm 1sR8LOdZ3JtA6K9Kn7+0y9J8U6jVSfM5T3EAbL5hgM5b9m4WJ3Bi6MCaVEV3BXNxnHjo ArXJqAp5NoPghdx6UQB6ID3A2DnIYkO0Ui/U3AOdDutPNFCcdepwFSctDzGvwHQgnipY mSNg== X-Received: by 10.68.227.36 with SMTP id rx4mr445203pbc.128.1383266766600; Thu, 31 Oct 2013 17:46:06 -0700 (PDT) Received: from himangi-Inspiron-N5110 ([14.139.82.6]) by mx.google.com with ESMTPSA id pu5sm8598122pac.21.2013.10.31.17.46.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 31 Oct 2013 17:46:05 -0700 (PDT) Date: Fri, 1 Nov 2013 06:16:00 +0530 From: Himangi Saraogi To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs:check-integrity.c: replace kmalloc with kmalloc_array Message-ID: <20131101004559.GA3258@himangi-Inspiron-N5110gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch replaces kmalloc(size * nr, ) with kmalloc_array(nr, size) as kmalloc_array() is preferred because it can check that the calculation doesn't wrap and won't return a smaller allocation. Reviewed-by: Zach Brown Signed-off-by: Himangi Saraogi --- fs/btrfs/check-integrity.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 1c47be1..d61ffef 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -3031,8 +3031,9 @@ void btrfsic_submit_bio(int rw, struct bio *bio) (unsigned long long)bio->bi_sector, dev_bytenr, bio->bi_bdev); - mapped_datav = kmalloc(sizeof(*mapped_datav) * bio->bi_vcnt, - GFP_NOFS); + mapped_datav = kmalloc_array(bio->bi_vcnt, + sizeof(*mapped_datav), + GFP_NOFS); if (!mapped_datav) goto leave; for (i = 0; i < bio->bi_vcnt; i++) {