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=unavailable 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 662D5C838CF for ; Tue, 27 Oct 2020 15:47:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BFDF21D42 for ; Tue, 27 Oct 2020 15:47:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WKldZ05u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765127AbgJ0Prm (ORCPT ); Tue, 27 Oct 2020 11:47:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26227 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1798549AbgJ0P2w (ORCPT ); Tue, 27 Oct 2020 11:28:52 -0400 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-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-xU4V-f77O3m2XA5APPV19w-1; Tue, 27 Oct 2020 11:28:48 -0400 X-MC-Unique: xU4V-f77O3m2XA5APPV19w-1 Received: by mail-wr1-f70.google.com with SMTP id v5so914637wrr.0 for ; Tue, 27 Oct 2020 08:28:47 -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=ffqqd5Mkf4ncfzL2zSvdSowNQJR24PyH3MDnsHAULqbeNhanboFKer5i8Kgr86Pu7A GGSPMc9wQuVvMqU8MGf9hzy7g1DZ0rA0hiBd5rEEquqdNPMDXd+JQQvozkxPaeU92Ygl jfGIvEFFdHfj9qvfwuD1qGqnUQ4NEiLCtogmLAhlZiBVXL1NACwLDoakMqbHW1guMWeI phbeOE60/ymTPIfZ/1O0HUMKm7X8ZZQP4sjPI28NrLC3FJBW4PbZ15bx9+7VO5lcC3Y6 9mrGHJ1RunGIlpoZM/tNoYtOmIl+qLj9shCbkyWN+y6d5njiLnJwq7wlSJGEBno17sas cC9A== X-Gm-Message-State: AOAM530xAoah9XsNOn9+lnzY2ISM5n205dh1Q+Y+k+PwY45BsCPgLyoG YHR5nag58niEbZ9sVf8cvaWxmfByhfWWqCJH5Jr/Wurafbh40F/DHonaSSpg2GHhvxJWxnc/9XV 6d7uYFPEYdKKtDxN/tXnHFQ== X-Received: by 2002:a1c:2cd7:: with SMTP id s206mr3177555wms.182.1603812526986; Tue, 27 Oct 2020 08:28:46 -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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027121725.24660-4-brgl@bgdev.pl> Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 6DEEFC4363A for ; Wed, 28 Oct 2020 08:12:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9068C20724 for ; Wed, 28 Oct 2020 08:12:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="IjoS3t46"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d7xbDRjj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9068C20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 047CB168A; Wed, 28 Oct 2020 09:11:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 047CB168A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1603872736; bh=I9wJXlD9PVGCgTYmHQ4SO54uv04OKKhHmkSKr4+jBVQ=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IjoS3t46sMShD80Y/G5gBFg9c6Ih74yRVjJWvF+0dhpGUyCvKHDbh53H/mNkr7bvJ DWU1CqoEB4GyHYfKEzCnpj+LSuv2vYCnvbsHo/WoPDCP6WdYeSfzyw+xVmiJzQlq44 ie2QIyk7CBDuELp48AWcjsWnpQprr/4ulptoVvoo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 31DB3F8051B; Wed, 28 Oct 2020 09:06:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DA397F8020D; Tue, 27 Oct 2020 16:28:59 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D1139F8019D for ; Tue, 27 Oct 2020 16:28:54 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D1139F8019D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d7xbDRjj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603812532; 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=d7xbDRjjLjeEvhiw7mqjgDGX3VuMUoomMciVmv0YKgMaZPut6z0vEv97siHsvwv8UUTeza /1DTh5nRa//2JOfEAnDH55hMpwPFTTvTbuI95HpY3JmzdFo5XmWEE2wQDjAQoBkMgJQSM/ IZtliz4GjC6Nx2Qb/9PxpBdXwE25qQU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-540-iCsUzPFHO_OboEGAEA0vvw-1; Tue, 27 Oct 2020 11:28:49 -0400 X-MC-Unique: iCsUzPFHO_OboEGAEA0vvw-1 Received: by mail-wr1-f72.google.com with SMTP id t17so884165wrm.13 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=D6VyV0PURvBiCw24ID0FbIdf9HugYWAA5gsIPtOiFRNJjVsthAzLewd2YU+WFPpvKW 1j2miClj8xTj6m7357dTBj4fAa6u1P+Mk/p2NawlUs7k5nH+KVHj2E7RAUFUplblon7f R4qUQE7Z1I4AE1lkanNbpiku/P4CP8nMfLZVI2n3Z55Q+B0E+5jIby0JWO/MSIi4ehzq /RmsLW1nLOTTQr1C8Z2yH5iX5Ilx/49hzw6oq1v8+1dTZZfKUbH/2X9IE23IbVlvO6iQ D94Ei72RHrSVNZAfr/HI8BbDtaqo6rjUjjdBvVUgu2z6yDSyHjdYSGl44uClTPPM5R9R s4ag== X-Gm-Message-State: AOAM531j+6imOgLEAIyxwyrnf8p0H3lEb+8ezEeZUJ8K2H6kV3U1jxOf DXqQ3jcAtYAG6+hOAdduexWXTVz4cipr40t7ckuobjlCU1tPdMnIzpEkxEiGFfWHolvvUUF7UjW 2NAO2D8AF1m81fo9o50g0+kc= X-Received: by 2002:a1c:2cd7:: with SMTP id s206mr3177577wms.182.1603812526994; Tue, 27 Oct 2020 08:28:46 -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 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-Mailman-Approved-At: Wed, 28 Oct 2020 09:06:29 +0100 Cc: alsa-devel@alsa-project.org, kvm@vger.kernel.org, David Airlie , Gustavo Padovan , Linus Walleij , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Christoph Lameter , Sumit Semwal , Mauro Carvalho Chehab , Bartosz Golaszewski , Alexander Shishkin , David Rientjes , virtualization@lists.linux-foundation.org, Jason Wang , linux-media@vger.kernel.org, Robert Richter , Thomas Zimmermann , Maarten Lankhorst , Maxime Ripard , linaro-mm-sig@lists.linaro.org, linux-gpio@vger.kernel.org, Borislav Petkov , Andy Shevchenko , Joonsoo Kim , linux-edac@vger.kernel.org, Tony Luck , netdev@vger.kernel.org, Takashi Iwai , linux-kernel@vger.kernel.org, Pekka Enberg , James Morse , Daniel Vetter , Andrew Morton , Christian =?iso-8859-1?Q?K=F6nig?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 C7916C388F9 for ; Tue, 27 Oct 2020 15:28:58 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25A1C22202 for ; Tue, 27 Oct 2020 15:28:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="StVGGlOw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25A1C22202 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 77AA42050A; Tue, 27 Oct 2020 15:28:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jCS-5fNFabxS; Tue, 27 Oct 2020 15:28:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id E34172048A; Tue, 27 Oct 2020 15:28:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D6A55C0859; Tue, 27 Oct 2020 15:28:56 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4980FC0051 for ; Tue, 27 Oct 2020 15:28:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4570887286 for ; Tue, 27 Oct 2020 15:28:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b8ub7DOCy5Y2 for ; Tue, 27 Oct 2020 15:28:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by hemlock.osuosl.org (Postfix) with ESMTPS id 91AF687031 for ; Tue, 27 Oct 2020 15:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603812533; 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=StVGGlOwtyvhP/3laWCb2RdgGghjqmvxjiuHFj/uDWwEjrCRxo7uHo6sUFMQvND77hfAIR WT+QPVvEaaNvCs0H1I+oBxeYYl4txCa4sKLUKeeaDhXUa9wrQBJu873e7nvCjUgmu/lwoJ vqz4OB+guTB2fYykjJQ83Q6BhRTKL1Y= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-h0qCXRVPPjKAyKByW_F01A-1; Tue, 27 Oct 2020 11:28:48 -0400 X-MC-Unique: h0qCXRVPPjKAyKByW_F01A-1 Received: by mail-wm1-f69.google.com with SMTP id s25so710919wmj.7 for ; Tue, 27 Oct 2020 08:28:47 -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=FNBMjoHp5yI1rn5bd8PgC1msrSSXF3yMxKqSJAehRlOh/jcOx4KMY+tHGbR8m2bD8K 33iR+sdaf3gRHRZtBBCnnS/GPR0NOz5Vvtbnb34InXOwjcffFNutspved/EqW1AwwDlM Ac9ErrrpN4Dr8AaqVrKGLylWi8IhUnB3NM9xK0ImfM4yL/jggYRMTADhyU3VEbuLEeE2 nThZ+SLaDCqSR084SWUjB4GM/Vcp9zB4sMhb67SUxnVenBtyhSXAj1BYvtXETsI+b+1c C16LH8/3p7BT4ssOf8A2bWHmEoP18jdrHFfZ/o/u/4nFVB2xdR4diaytXG3Yq3GSixFW JBiw== X-Gm-Message-State: AOAM533hHl4mFrg1iGCWLMv77Vp6Uy/5Qjm1VO9zANFLhzp1vhSsY4S8 YfYg0thpBA8syWq9U0j2cAyyC4w0EjKbD1PJ7Tt5ttXxpB1wAwzsbpi1tG3rHtnt50UXHkwKSvq r5zJ+gEeWeQHaLrUpG89djkV83UGdQQ051Hi809byDg== X-Received: by 2002:a1c:2cd7:: with SMTP id s206mr3177554wms.182.1603812526986; Tue, 27 Oct 2020 08:28:46 -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 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-Disposition: inline Cc: alsa-devel@alsa-project.org, kvm@vger.kernel.org, David Airlie , Gustavo Padovan , Linus Walleij , dri-devel@lists.freedesktop.org, Jaroslav Kysela , linux-mm@kvack.org, Christoph Lameter , Sumit Semwal , Mauro Carvalho Chehab , Bartosz Golaszewski , Alexander Shishkin , David Rientjes , virtualization@lists.linux-foundation.org, linux-media@vger.kernel.org, Robert Richter , Thomas Zimmermann , Maarten Lankhorst , Maxime Ripard , linaro-mm-sig@lists.linaro.org, linux-gpio@vger.kernel.org, Borislav Petkov , Andy Shevchenko , Joonsoo Kim , linux-edac@vger.kernel.org, Tony Luck , netdev@vger.kernel.org, Takashi Iwai , linux-kernel@vger.kernel.org, Pekka Enberg , James Morse , Daniel Vetter , Andrew Morton , Christian =?iso-8859-1?Q?K=F6nig?= X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" 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 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization 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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 39033C56202 for ; Tue, 27 Oct 2020 15:28:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C044A222E9 for ; Tue, 27 Oct 2020 15:28:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="StVGGlOw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C044A222E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0DD076EB95; Tue, 27 Oct 2020 15:28:55 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7480D6EB95 for ; Tue, 27 Oct 2020 15:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603812533; 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=StVGGlOwtyvhP/3laWCb2RdgGghjqmvxjiuHFj/uDWwEjrCRxo7uHo6sUFMQvND77hfAIR WT+QPVvEaaNvCs0H1I+oBxeYYl4txCa4sKLUKeeaDhXUa9wrQBJu873e7nvCjUgmu/lwoJ vqz4OB+guTB2fYykjJQ83Q6BhRTKL1Y= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-NybRYwN8Mwy5lzwjEDlU2w-1; Tue, 27 Oct 2020 11:28:51 -0400 X-MC-Unique: NybRYwN8Mwy5lzwjEDlU2w-1 Received: by mail-wm1-f71.google.com with SMTP id c204so716407wmd.5 for ; Tue, 27 Oct 2020 08:28:50 -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=cIjiZOUrec34TBFs1xrbNchPFkKN5QljeSO+MRq7U5frYkQLpxd04v6Sye+JTmWrKE a0s7pP9N2/5wqmZ2nM/ojdmZwF7y8WU/XcYl1eqN7f/FCVJQiq62Y8SE2IBayJwhT0bC 4B5+lQWByyL4CpTD8mJUPjVANaDRPULRXRDZvs1GgWFGTJvtKubaBXs9jnw8+bzhXmlp 9O/k+1VkoPeoVseRV9qZD91Qfc8kF7RmJ6cxrwaiiGLqKklu8Z+6tzWolrBnMxSuX6e8 c0vnfYo91+PqE4VbGF3B0DYB8pRjJ44Hvu51GimrpkpOE6cRBzgXEkZRiMxKDJv5enTL PCog== X-Gm-Message-State: AOAM5304jsYFc0ymEZI+uRvOU+TW3YgwrvxKjoBaJmpqX4FCe3aQAqqf /WljIfgsTKBG8yX3Vfr8kQLxU5PT835VVM3Sr/D7aEHn0XGxydhVryyI1gkkGXv+3TvUgZaO0x8 8HJmjrxY3iyBR1iTXjRRAMvgQidBD X-Received: by 2002:a1c:2cd7:: with SMTP id s206mr3177569wms.182.1603812526990; Tue, 27 Oct 2020 08:28:46 -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 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-Disposition: inline X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, kvm@vger.kernel.org, David Airlie , Gustavo Padovan , dri-devel@lists.freedesktop.org, Jaroslav Kysela , linux-mm@kvack.org, Christoph Lameter , Mauro Carvalho Chehab , Bartosz Golaszewski , Alexander Shishkin , David Rientjes , virtualization@lists.linux-foundation.org, Jason Wang , linux-media@vger.kernel.org, Robert Richter , Thomas Zimmermann , linaro-mm-sig@lists.linaro.org, linux-gpio@vger.kernel.org, Borislav Petkov , Andy Shevchenko , Joonsoo Kim , linux-edac@vger.kernel.org, Tony Luck , netdev@vger.kernel.org, Takashi Iwai , linux-kernel@vger.kernel.org, Pekka Enberg , James Morse , Andrew Morton , Christian =?iso-8859-1?Q?K=F6nig?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel