Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2537074rwb; Mon, 3 Oct 2022 02:10:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7FWwjUuJgHGNsDlAsGzpZJThAjrtxneKcdRMNjJXjQWrjApxqwSVvBW8cevLNvcmh35/Qu X-Received: by 2002:a17:90b:1b4c:b0:202:c1a3:25ce with SMTP id nv12-20020a17090b1b4c00b00202c1a325cemr11374166pjb.232.1664788204277; Mon, 03 Oct 2022 02:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664788204; cv=none; d=google.com; s=arc-20160816; b=WbcgVr4LHN3OYDo3cshFIgfX9WpMr2tZ51lWHhUDKKS70jDat7LcVDugtoILXdYBcP MBCbv8Sqtg2+SrQrcX3mMo1ZcS5OGt9xvjfN4gB0JwaOGXVoDwpwbgIyyHDRJY3OdV3D TcJzaCzEHD5OhVVTWJ1LhkOYBmTAhEoHBnDj/ljQPNgYqr0RBEdj2oBRZZpArsrlN7kM A7/CDVSAPier3SkIWdvmUWYyJlSrnfNhHfNOjVbwEbommzrUf/JlPnMCe7MPvCa5yqv1 4BN2Wl52a+S8NM9iLXR7tBJOj9fGGySc/Pfi9cNl6jNuUgdXJDO4FHgAx0jVWe2Pd1i7 M+Gg== 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=Xf70ZdDqzx7jo7kIFvQ1kPrkwt4zvRNJ1X1Wv+CIEXc=; b=gAeP/JWi3ZT+d24FV8PEkZV6eGFTjsCsXftPPinQmBsP1stSSDXYft+FuJKIEzghh5 mgA5DBpLLLEyaZP6bjbkhaYgK1S2y06XOimRoekPNily1bfbxjPSqKcqxwYK5IHkyQ6L H33QBNL94laQeB5CpkCbExaRoq5apZdWlM27B3qf1HmjGR28ahNDmGhXWBGWGUkoOUGj bGACRvfdrstajkyM27x5zes8/dJXqmx9CG+SdViyGaR1bI6pgYzuUm2s00dqA0goiNLp wzERXMhjMcq01/WFexW0pOo1S8Ol+czAoPh9Az3Yk2eZ9uWR7NKfG5N2zyERVAMxZ17A CyCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=erzvKXW0; 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 oo18-20020a17090b1c9200b001efa292580bsi11220859pjb.187.2022.10.03.02.09.52; Mon, 03 Oct 2022 02:10:04 -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=erzvKXW0; 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 S230023AbiJCI6q (ORCPT + 99 others); Mon, 3 Oct 2022 04:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbiJCI6T (ORCPT ); Mon, 3 Oct 2022 04:58:19 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A21F5A837; Mon, 3 Oct 2022 01:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664786611; x=1696322611; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=POqTCHFhgHZP4PJehVBeukvn0cF46F+fSY63iPQxsWs=; b=erzvKXW07gb1W+yOCC2k25dAh3JjXyjzsu1Sw2QtQPXRjJEMxHCaJ2l7 /590mUdywQFEA2jG0gPkZtHzdAzPbT1D/yMUrAbe+G+lSR6iJ03gAlGd7 Ec5ImAL8nYqUDBtMQl1Kz9RYc9a4kdEyu8RxculfjAcK0wbvNLVFueGHB Soezv7i/DnjTXUTQvR1d0R6kEqw9aUUiO3hVd31i0NRYVEjFBTgM/+0K+ Qj50WUZA0VJBFhTBCd0s09MoZdsZUEs8L6fVqGTC3u3vAbDD4qdKxYXdw NVhRAxv7t2LLO+ZmXDvPGlhe/dBCmtCjnokNTH0jCcxs9XfcTb15WoZYQ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10488"; a="328974358" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="328974358" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2022 01:43:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10488"; a="748908010" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="748908010" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga004.jf.intel.com with ESMTP; 03 Oct 2022 01:43:23 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1ofH2n-001Pzs-09; Mon, 03 Oct 2022 11:43:21 +0300 Date: Mon, 3 Oct 2022 11:43:20 +0300 From: Andy Shevchenko To: Matti Vaittinen Cc: Matti Vaittinen , Lars-Peter Clausen , Michael Hennerich , Cosmin Tanislav , Jonathan Cameron , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Benson Leung , Guenter Roeck , Alexandru Ardelean , Nathan Chancellor , Miquel Raynal , Miaoqian Lin , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Paul Cercueil , Mihail Chindris , Gwendal Grignou , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev Subject: Re: [RFT PATCH v3 10/10] iio: Don't silently expect attribute types Message-ID: References: <63f54787a684eb1232f1c5d275a09c786987fe4a.1664782676.git.mazziesaccount@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <63f54787a684eb1232f1c5d275a09c786987fe4a.1664782676.git.mazziesaccount@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 Mon, Oct 03, 2022 at 11:13:53AM +0300, Matti Vaittinen wrote: > The iio_triggered_buffer_setup_ext() and the > devm_iio_kfifo_buffer_setup_ext() were changed by > commit 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr") > to silently expect that all attributes given in buffer_attrs array are > device-attributes. This expectation was not forced by the API - and some > drivers did register attributes created by IIO_CONST_ATTR(). > > When using IIO_CONST_ATTRs the added attribute "wrapping" does not copy > the pointer to stored string constant and when the sysfs file is read the > kernel will access to invalid location. > > Change the function signatures to expect an array of iio_dev_attrs to > avoid similar errors in the future. ... Wouldn't be better to split this on per driver basis or is it impossible? > drivers/iio/accel/adxl367.c | 10 +++++----- > drivers/iio/accel/adxl372.c | 10 +++++----- > drivers/iio/accel/bmc150-accel-core.c | 12 ++++++------ > drivers/iio/adc/at91-sama5d2_adc.c | 12 ++++++------ > drivers/iio/buffer/industrialio-buffer-dmaengine.c | 4 ++-- > drivers/iio/buffer/industrialio-triggered-buffer.c | 4 ++-- > drivers/iio/buffer/kfifo_buf.c | 2 +- > .../common/cros_ec_sensors/cros_ec_sensors_core.c | 6 +++--- > drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 8 ++++---- > drivers/iio/industrialio-buffer.c | 11 +++++++---- > include/linux/iio/buffer_impl.h | 2 +- > include/linux/iio/kfifo_buf.h | 3 ++- > include/linux/iio/triggered_buffer.h | 6 +++--- ... > struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); > struct iio_dev_attr *p; > + const struct iio_dev_attr *id_attr; I'm wondering if we may keep this upper, so "longer line goes first" rule would be satisfied. > struct attribute **attr; > int ret, i, attrn, scan_el_attrcount, buffer_attrcount; > const struct iio_chan_spec *channels; ... > + for (i = 0, id_attr = buffer->attrs[i]; > + (id_attr = buffer->attrs[i]); i++) Not sure why we have additional parentheses... > + attr[ARRAY_SIZE(iio_buffer_attrs) + i] = > + (struct attribute *)&id_attr->dev_attr.attr; ...and explicit casting here. Isn't attr is already of a struct attribute? -- With Best Regards, Andy Shevchenko