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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 115DBC433FE for ; Mon, 3 Oct 2022 08:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6Ab95d+2huzT3SszrQO3bYWH7uIsGvarzqVz39K9kkE=; b=LcXMhNi72DzeYg NNRQtcW/Vle3rjbP8fcUjPZmzJnktqY6Xt0MABVnEsfEfQhetfVD8ap9PsuPFIwNXJpTPYCL6OMuN HQPym35xrj67ui9DRtrUWuyncdaRXlGn5GARDPd0Xx2YZFfwKOJA+aGFJ3ebzKjhjSjgGNq9+RJ2g CBdpBdwOnEQOa/JLsLE6rt3WoZzZio8A5To+EyaRbvOLDdZRA44uqzH11fxrKl/LcLETXAnWtLr87 fis1ksk2oGy9zf1MZxDN9Yn1titNkAWS670s2s07WaH9RVGbWoXPcUr8E4uuKb6byrAqK+KVxRa9t DjlUFBE/Rb0Pf8+UH05w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofH34-004lm6-6n; Mon, 03 Oct 2022 08:43:38 +0000 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofH30-004ljG-K9 for linux-arm-kernel@lists.infradead.org; Mon, 03 Oct 2022 08:43:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664786614; x=1696322614; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=POqTCHFhgHZP4PJehVBeukvn0cF46F+fSY63iPQxsWs=; b=DkJDH88C59w8kHsNdcJNb+Q1r2ob6uCj5CinrBer8Uz/4w4KxaAC4sFD JLFgmO18RHo+PLx5sVH0M063nr719bX7l9t6OtENEuI3IpBWnJuwkYoFI o/xuBbEJNwuQ8hmNOfc8LVHYkI5bLpEVrLEdFQry7rCRrfvvSGHlHbKsl 9lV6aN2/56WYWxeV+oELWoGYA3Wmtg2N2jpRfiif1wlUp/EcNFv9qNAX+ HAWkxKkVQVG3+DNo1SdjJzIoDtd0lwtcblDQHdRxPy9HWGxkPVKUFX6d7 VtqEjopkEOPfAKrM3rzH3frHYylTRYVazOhOPsuZHzIf0jqgzEiJHPcD1 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10488"; a="364426035" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="364426035" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.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 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-Disposition: inline In-Reply-To: <63f54787a684eb1232f1c5d275a09c786987fe4a.1664782676.git.mazziesaccount@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221003_014334_741749_35409E2B X-CRM114-Status: GOOD ( 20.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , linux-iio@vger.kernel.org, Gwendal Grignou , linux-kernel@vger.kernel.org, Paul Cercueil , Miquel Raynal , Guenter Roeck , chrome-platform@lists.linux.dev, Lars-Peter Clausen , Miaoqian Lin , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Alexandru Ardelean , Mihail Chindris , Michael Hennerich , Cosmin Tanislav , Nathan Chancellor , Benson Leung , linux-arm-kernel@lists.infradead.org, Matti Vaittinen , Eugen Hristev , Claudiu Beznea , Jonathan Cameron Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel