Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp122560pxx; Tue, 27 Oct 2020 23:41:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX7wtu5TNc0H8khwvBVadHaxkBY5ebWaaFhUS8c+xUoqPxeC7Y3Kn2/DK33QO+rd75bSYs X-Received: by 2002:a17:906:31c6:: with SMTP id f6mr6224849ejf.164.1603867263075; Tue, 27 Oct 2020 23:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603867263; cv=none; d=google.com; s=arc-20160816; b=YxVFsYUefXDLmDgAq6F8fzRZ4SFY4ZZrRAkPY8zT5u7r8kV/68jg2Nvm/RzveFltdx mI+8N2VZjGcokgmFykZ7b5oxGd29u4zN7m2QGYfTRa1FMiQryjNehB6UwqYQ1FDxQk9/ D5eCtBMeCTlAAJBzQx4DAW14WP8a0PUvxKWRQBCyfUFbm/3jDOBUC8kqAyrrMOLI9rEc eYVf4BdAP/zlT6ggpe0gHcRyHfNVzwPvxbQamrFM7idWTeaePFRD5uXAx1YpVEOftL2P ni/jFsn/RljrXmSW1ewk01//FbnkQF13PB3f383gMP2QSaMCbzUmK6AqneMpeOJ8frYJ zClA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Y1DHuCLMehbCpMeVCXiA9IVd7bv7Jzb8nCFvlPiTlBI=; b=iSp2t7QV9iH7anFIxWmqgo1UeEbR7etXXF2L764vuPdQUiztzUObzjHP9/C6FvHVI4 HkHcuxcWdIwfrKLUeI4MSFZGpL5p9GsLBrsUh8vicEOii+KreL0b4dF8v6vQORDUJlmg nDlQd8jO3/xN0DHtY6rdvuEpR85orcLnEeyUmew2ZLL2FKTHTRQkFpG3VpsOiIbcsl0l h+bS3AEXvbO3unOREye6+ZbXCND34wyfET5VWfs854JoLttqIK1AQxoj8FqRHRS25iu0 d+BhMSTdBDZnha/gI3JYftZyrz+g8iw6xZbDPFF9XbIGgUoSh14fB50ffG4WHQ3vWTQu z2Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=bPAQEkL5; 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 w14si2545272edt.78.2020.10.27.23.40.41; Tue, 27 Oct 2020 23:41:03 -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; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=bPAQEkL5; 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 S2897260AbgJ0KFF (ORCPT + 99 others); Tue, 27 Oct 2020 06:05:05 -0400 Received: from mail-il1-f195.google.com ([209.85.166.195]:34637 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2897238AbgJ0KE5 (ORCPT ); Tue, 27 Oct 2020 06:04:57 -0400 Received: by mail-il1-f195.google.com with SMTP id v18so975506ilg.1 for ; Tue, 27 Oct 2020 03:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Y1DHuCLMehbCpMeVCXiA9IVd7bv7Jzb8nCFvlPiTlBI=; b=bPAQEkL551vUGzj7Vhpa0oB+ZaEBF1GHpc9HjvS3f5+TaI1F3RACJojIh7O712IQ0L 4b/Oy8bEXirxPPxu+WRdI5uSCfz4K5UIg2WouLADsotYj4HJg3GiXsKtuF8lI8OV0qW6 qHF0ZJIhsdNkwofVkFpz1ofbcmCPm/9PgPfVHWFfolvOVBmLAgLL/DILHNJ3mOvN9ySa EKyS1faIq5vNausUdfcdqDd2xlispV9lT6fpMqPjHSUgf6U3TPoOmkdOR+XGDiYEC+dY 0rKb7sIUmvwsx5NbbP+Yvikc1sX5FHffVOuIbqBbHxUHeAfBvWPnxB+fmjRlZsql54am afNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Y1DHuCLMehbCpMeVCXiA9IVd7bv7Jzb8nCFvlPiTlBI=; b=Uc4eq2nRdvuIUF/QN9BgMZwVfU13j0fPxv9l1NYmOZ6/8GA8XaGyY7WqpqcnEpMA1D seO9faepXmTX23IRJ1d4e8nLpQs4EkVBDvTF8gE/92H302HukyxvcBWnSXIPjZMfRhS2 9Yz+2DU/ELDXr6xaLzjEJ5UCpWPm5IRcyQKkwHyfxb35qeXJJNzL197418JODlT1IFHQ zDKEaJo9z+vPE/t6EnO6bxvAiSoOOx/mmJbTlfB7ybrybKAu6kuSqyywLbv8oenIjLgn nCuT6HimBN2jPkpqgdCrxaCw6w3lIH4vbu4SrJr6nh5sfzBt7U49AyWvfpGjLOSuw7Rk 5OSg== X-Gm-Message-State: AOAM530pLaooVMPAZUUpIKmXG5ZEqkE4St48IyFchmgSezpSaZb2xqK/ 4nnnSFlv82dlow9AsXBKcTxUO8QLrwHK91sqIGLDpQ== X-Received: by 2002:a92:b610:: with SMTP id s16mr1201682ili.6.1603793094884; Tue, 27 Oct 2020 03:04:54 -0700 (PDT) MIME-Version: 1.0 References: <20201026133609.24262-1-brgl@bgdev.pl> <20201026133609.24262-3-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 27 Oct 2020 11:04:44 +0100 Message-ID: Subject: Re: [PATCH 2/5] iio: adc: xilinx: use devm_krealloc() instead of kfree() + kcalloc() To: Andy Shevchenko Cc: Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , Michal Simek , linux-iio , linux-arm Mailing List , Linux Kernel Mailing List , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 27, 2020 at 10:33 AM Andy Shevchenko wrote: > > On Mon, Oct 26, 2020 at 4:03 PM Bartosz Golaszewski wrote: > > > > From: Bartosz Golaszewski > > > > We now have devm_krealloc() in the kernel Use it indstead of calling > > kfree() and kcalloc() separately. > > Which is completely lawful when size > previous_size (I mean, the > additional patch you sent previously seems not related to this). > Sure but devm_krealloc() is cleaner and adds the benefit of resource management. > > - kfree(xadc->data); > > - xadc->data = kcalloc(n, sizeof(*xadc->data), GFP_KERNEL); > > + xadc->data = devm_krealloc(indio_dev->dev.parent, xadc->data, > > + n * sizeof(*xadc->data), > > I think you need to use something from overflow.h instead of explicit > multiplication here. > Or maybe add devm_krealloc_array() which would perform the checks behind the scenes? > > + GFP_KERNEL | __GFP_ZERO); > > -- > With Best Regards, > Andy Shevchenko Bartosz