Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2947187rwo; Mon, 24 Jul 2023 04:06:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+uGB2U4g24QtgSo6cCU1lY8/UyMo6hqBlAkp6Y+PFwDoYoeE+QRjkF9TcGua5GQXeO8Vt X-Received: by 2002:a17:902:c085:b0:1bb:809d:ae72 with SMTP id j5-20020a170902c08500b001bb809dae72mr4110471pld.33.1690196775352; Mon, 24 Jul 2023 04:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690196775; cv=none; d=google.com; s=arc-20160816; b=JC4Ajt+jNBr+LHJvLLCyYNGwkf46a8RFssXXrGWjyfzll0UyUMRkQwgablVls7A2Hd sujhP7HecCoRdffU8E0vNuKG83fKGnDvNvuCLmjcLOOrnrg2RpDeCF6eJ3H8hdokYQsn 7ajVcDl0PQIA/xy5z2vRW3Iksyv4+H1a0ppMFZTWLfMKjt0PoMQJ42cwu4ZGajkTJ2KB XwAKwgsppjQztXayUYqnnvuY3L6zsPdW0wl3W8qonrRX9jCuzktRrq7ukLVvlMN6kEhk cwrbCGBINY2aquEkUyM8Sc+XgQHTdYa2O4HpyXTT4uVZd+cY2ab3byCaqXhkIS4e6Swl WVjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=mPPisGYVmBFsb0XWk5LT/ZzVgKxesJQgYqV1xhyF5m0=; fh=IFKvaMIk0m3G0tjS1Lli3FK2jqW7rpOirXMNagPXhhc=; b=oyFYe15N8aQCKdElk1vTLQKGXExK/dh/0Z3jmBRjWrMkVR/6iIj0v5mifO8x28/Za5 qGppocRAz1Qy6tFi4TDz26Mt0MaCF96QQYnQJXH2WvjoZicigqzgCXCpLCJkT8cOovSY yqjkE58yJgx9XWSFi/FGRd77iobNyhgrlTk7qyQRCxmu4V4yeuG1iKDk3sADfuakX5LD oC3YpIqNNyDUJaUWF+4GEWh9l8O9UfQPrJzJ2gOtng4rioma7zZvSAh2RCqsYL7aI9NI fp1IcNbQicMUbnypnpOUhE10kd0+4tsQcvT8U/68pwB/GXzrxzkYf8cKnu8UvmNCeRlw tKiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="S/VhcWPu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky6-20020a170902f98600b001bb5fd69932si8158156plb.367.2023.07.24.04.06.02; Mon, 24 Jul 2023 04:06:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="S/VhcWPu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231811AbjGXKi5 (ORCPT + 99 others); Mon, 24 Jul 2023 06:38:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbjGXKiz (ORCPT ); Mon, 24 Jul 2023 06:38:55 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66B60E64; Mon, 24 Jul 2023 03:38:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690195105; x=1721731105; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=tW+M2N9Q+IxZ0D9H/5OTffwd2d4CE68kUFZWbzqXWTU=; b=S/VhcWPuMCNMc4zdsHM8FQv+vfeWvS0wnSScCbUHaMLZJdEjR1F3Yt9J KKr9tZUkfUW3PQhXXIlv9neuJR65oXPK6/OqfuDXEsaGLMdIVZoBGrnkt dLaklklgLeGY7htJPtA37pjN7uxioSQlpPjzCZQQQNF57hCA2tg2+tJ7V vdUWyZwRS3whf1Qdd9Gj+9jNkI3kg1Ur+nIkCWvwWkyi7i6zi2jPqgwe9 iRRUTLHrTRKtsiXT6m9Yw1Szu6rHPPiblKjzg0or/JfBL3+d20flkjwuf f/6kwJpdGJtp7K/9aRw/KYLYsBQNc/PyU+ykF6t9cNqUFx0XLsh5maBXF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="398308492" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="398308492" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 03:37:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="675784266" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="675784266" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga003.jf.intel.com with ESMTP; 24 Jul 2023 03:37:48 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qNswk-008vQd-2A; Mon, 24 Jul 2023 13:37:46 +0300 Date: Mon, 24 Jul 2023 13:37:46 +0300 From: Andy Shevchenko To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Lars-Peter Clausen , Nuno Sa Subject: Re: [PATCH v2 3/8] iio: core: Switch to krealloc_array() Message-ID: References: <20230721170022.3461-1-andriy.shevchenko@linux.intel.com> <20230721170022.3461-4-andriy.shevchenko@linux.intel.com> <20230722182820.28fb3115@jic23-huawei> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230722182820.28fb3115@jic23-huawei> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 22, 2023 at 06:28:20PM +0100, Jonathan Cameron wrote: > On Fri, 21 Jul 2023 20:00:17 +0300 > Andy Shevchenko wrote: ... > > + krealloc_array(attrs, attrcount + 1, sizeof(*attrs), GFP_KERNEL); > > > I'm a little lost, but isn't this realloc()ing attrs, which should be provided > by drivers as constant if it is set to indio_dev->info->attrs->attrs? > > That seems unlikely to work correctly, but I may well have lost track of the > flow and attrs points somewhere else at this point. I guess it might work > as the realloc code will detect it can't resize that array. Argh! The attrs are defined without const. So, basically to prevent code like this we have to make sure our local variables are defined as const. I will drop this hunk from the next version, need to think if it makes sense to refactor and if so, in which way. -- With Best Regards, Andy Shevchenko