From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38B36C55179 for ; Tue, 27 Oct 2020 15:28:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B40DC22281 for ; Tue, 27 Oct 2020 15:28:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WKldZ05u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B40DC22281 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C96216B0070; Tue, 27 Oct 2020 11:28:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1FBE6B0074; Tue, 27 Oct 2020 11:28:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE64C6B0075; Tue, 27 Oct 2020 11:28:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 781E36B0070 for ; Tue, 27 Oct 2020 11:28:53 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2956E1EF1 for ; Tue, 27 Oct 2020 15:28:53 +0000 (UTC) X-FDA: 77418088146.04.sheet29_3c0e4572727d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 0755E80081CD for ; Tue, 27 Oct 2020 15:28:52 +0000 (UTC) X-HE-Tag: sheet29_3c0e4572727d X-Filterd-Recvd-Size: 5840 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 15:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603812531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mlWO+8V1OcYguip2KBsMhYWBSFJwL/+zUDmEZaIbfJ4=; b=WKldZ05uRRnd7jfUDf+eXY82dU6qVMRserWCR3AQCKsYULu3T/y8B1yqIJaoitr6iizuYf Hx7lIZ9x8eFNLDGBeLFdrw9z15q1vuarALmscrBIZPINoUz/eJ8klX323OFv0aC1cstaWE Yh5Pr3+u/a7yyxYmFlfv0y6WmGdUXC4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-l6Q4tGovOcunJD3-befN4w-1; Tue, 27 Oct 2020 11:28:49 -0400 X-MC-Unique: l6Q4tGovOcunJD3-befN4w-1 Received: by mail-wm1-f72.google.com with SMTP id r19so706331wmh.9 for ; Tue, 27 Oct 2020 08:28:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mlWO+8V1OcYguip2KBsMhYWBSFJwL/+zUDmEZaIbfJ4=; b=FWejvdc80qQOOi2j4cavoSrh4cwRq7Q+f3dyE1qjVtQiMobCafXSOhSCSTM9OPQmdF a9Kr26752MgNrkSmEaoFrNGc59hazNUsmnHJDL7cNR7OdPxFLd41TtHpBsHfKPEwuEWc O444TqiuOKk7Z823m8GlPYoD6bdgwnR9DAKRflXFWYDTRXZSDqIORCkM24TMBndwNV/w f1P+/Z0pZ2QOKQaDQoiQTHpAYWBrK3nK69QVahaMQ7aNbkX+d02xJ6FDt9n0hXAqkaN8 mthdJKybW3fTyuNqZPa65shQcqyawzvOHQOVpwHLevGz4Ql1IV0P9psiOvhsZYF2dheZ JEUA== X-Gm-Message-State: AOAM530HLs7pBQqctJkOfYH3M71fYWLXU3W7h/lm08mcFi/6wzVsQUoy ZHnXbYeUsS4+j7CxGm5CQQeaBXoMVZYqLE/xI/TFNAVvPwIRNql5pcmwladIaGocXElrv6pDoYm VAVc0DXATUNE= X-Received: by 2002:a1c:2cd7:: with SMTP id s206mr3177595wms.182.1603812527230; Tue, 27 Oct 2020 08:28:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuH3n7lQ9eR5dnqf6yc1oFeHmyleXhbTjubsRyj6zs3Jak/y/oaUl12gqM18qHQ8tFGKD6AA== X-Received: by 2002:a1c:2cd7:: with SMTP id s206mr3177537wms.182.1603812526789; Tue, 27 Oct 2020 08:28:46 -0700 (PDT) Received: from redhat.com (bzq-109-65-21-184.red.bezeqint.net. [109.65.21.184]) by smtp.gmail.com with ESMTPSA id 3sm2370433wmd.19.2020.10.27.08.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 08:28:45 -0700 (PDT) Date: Tue, 27 Oct 2020 11:28:40 -0400 From: "Michael S. Tsirkin" To: Bartosz Golaszewski Cc: Andy Shevchenko , Sumit Semwal , Gustavo Padovan , Christian =?iso-8859-1?Q?K=F6nig?= , Mauro Carvalho Chehab , Borislav Petkov , Tony Luck , James Morse , Robert Richter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Alexander Shishkin , Linus Walleij , Jason Wang , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Jaroslav Kysela , Takashi Iwai , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-gpio@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-mm@kvack.org, alsa-devel@alsa-project.org, Bartosz Golaszewski Subject: Re: [PATCH 3/8] vhost: vringh: use krealloc_array() Message-ID: <20201027112607-mutt-send-email-mst@kernel.org> References: <20201027121725.24660-1-brgl@bgdev.pl> <20201027121725.24660-4-brgl@bgdev.pl> MIME-Version: 1.0 In-Reply-To: <20201027121725.24660-4-brgl@bgdev.pl> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Oct 27, 2020 at 01:17:20PM +0100, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > Use the helper that checks for overflows internally instead of manually > calculating the size of the new array. > > Signed-off-by: Bartosz Golaszewski No problem with the patch, it does introduce some symmetry in the code. Acked-by: Michael S. Tsirkin > --- > drivers/vhost/vringh.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c > index 8bd8b403f087..08a0e1c842df 100644 > --- a/drivers/vhost/vringh.c > +++ b/drivers/vhost/vringh.c > @@ -198,7 +198,8 @@ static int resize_iovec(struct vringh_kiov *iov, gfp_t gfp) > > flag = (iov->max_num & VRINGH_IOV_ALLOCATED); > if (flag) > - new = krealloc(iov->iov, new_num * sizeof(struct iovec), gfp); > + new = krealloc_array(iov->iov, new_num, > + sizeof(struct iovec), gfp); > else { > new = kmalloc_array(new_num, sizeof(struct iovec), gfp); > if (new) { > -- > 2.29.1