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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C0BAC001E0 for ; Sat, 29 Jul 2023 11:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbjG2LsT (ORCPT ); Sat, 29 Jul 2023 07:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjG2LsS (ORCPT ); Sat, 29 Jul 2023 07:48:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BB4D3580; Sat, 29 Jul 2023 04:48:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C006F60BA7; Sat, 29 Jul 2023 11:48:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42184C433C8; Sat, 29 Jul 2023 11:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690631297; bh=fOokmcypwHXt1MVBFRHJON7bgOFC378lqsy9wG3kr84=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mQ02B9HNtqr3K8RLw+pz+hIlUHLEh3jCvMykxY6NiYN+rASPE71QOF62SxGa6FR2z qJx/o8mUs9BblyUig+tPS+D0q8rpK6Awmipljd48ku8Rm+Bue9Xrv9SwFQ943iqb1a YFqXH+g5/x0Jp/SGMlwu5LxSFo9PPZEftCS8DUiE34Uw0DRZg53wAVpq9npP5QBGNW ketx2gxu+VljOuow+1ym1miFZLxY2OXITR9fBHWHcLozwKHvKqmkieubqRdyMutTJH 4XRxbpst5HX4GmZPzCgCfBi6Xoed96SGbTTqLYTHnU/F4hAzE8bFWBexNhejNHBUGm 0zFrepheifHFA== Date: Sat, 29 Jul 2023 12:48:22 +0100 From: Jonathan Cameron To: Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Lars-Peter Clausen , Nuno Sa Subject: Re: [PATCH v3 3/4] iio: core: Switch to krealloc_array() Message-ID: <20230729124822.578d14cc@jic23-huawei> In-Reply-To: <20230724110204.46285-4-andriy.shevchenko@linux.intel.com> References: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> <20230724110204.46285-4-andriy.shevchenko@linux.intel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Mon, 24 Jul 2023 14:02:03 +0300 Andy Shevchenko wrote: > Let the krealloc_array() copy the original data and > check for a multiplication overflow. > > Signed-off-by: Andy Shevchenko > Reviewed-by: Nuno Sa Applied Thanks, Jonathan > --- > drivers/iio/industrialio-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index 118ca6b59504..13d6b6ac5ccf 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -1474,7 +1474,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev, > const struct attribute_group **new, **old = iio_dev_opaque->groups; > unsigned int cnt = iio_dev_opaque->groupcounter; > > - new = krealloc(old, sizeof(*new) * (cnt + 2), GFP_KERNEL); > + new = krealloc_array(old, cnt + 2, sizeof(*new), GFP_KERNEL); > if (!new) > return -ENOMEM; >