From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795907799; b=FA2D4FGrZw85gS8F9Ga7dqv3XI/G1TVBjSRm44yQdqRTubsKgg2Sz+blMbKXQJ98mjTJ RvTTAWF7tMMcqMumNNzm/Ptip9XeB0W94M7Vn881eVEtB3jM+hmK+g1J/Ue5rRKRyonQ0 9edjtPi4z89GrSH/2Pagxc8E8CLwyqIBXFAfRbo6l5QNRjSZRhflWmfMbAsTGrO+PvOUS DmXD52zKPZBr2qG81TrPytqLylcZJG78qu8UKqAAmyJyFwhMxcHFsxFMG9PBZY9ZMa3gk w9HUWof8CMf8az9y5ysJxXIB3hTPeQtjmFh846RODYsKLalNsqEUTIEd6A+x2euSPyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795907799; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=wKONXkOfxq2WpJtQTnR4xcfvbKGreesklQFHtUqDxhE=; b=QHbminZvbkA4inzfotvZammahIKTsDWQ4wy3mPrEC/nGWFN1l8tNe8ffOMne3OBFL9CG phuJy34sO3p4jA6j5yyGRKIb3qBwpY8jRnVFcs58+N3cBgjJvqkGZddBdfP3503DSnZ7a SsxjZlZY+00zXB5pNkqG2kh4l+AuWugzjU3NyBd3e/iVzw7TWWm+P5lh3oMQTyxdgDWXz WbgcqjAv1Xp2AOU68/bWAWt8kH0A35I0zwS2SahOTaeB2IL7vl9Li//ZrJ1oCmfZQYXOn 93eiqviziHd0FfzkGAlhXbBDwMbUzOIUsyklSMJQcYY4tL26MeUCC2eTbJtLecA2U7w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Yf1JWxJk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9658B606A321; Sat, 28 Nov 2026 23:16:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Yf1JWxJk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B0D31F00898; Sat, 28 Nov 2026 23:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795907799; bh=wKONXkOfxq2WpJtQTnR4xcfvbKGreesklQFHtUqDxhE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Yf1JWxJkI8D4IGnYutRoO+aVr/Nfr9xFhGtlpVCdc8fzouWhRZxMHQSWC6U2BtJNz 7ZX80/6WXx39jP3dVVM5/ozCc6eBSPNn5xszz7pmb+fFayocfQXQ77t4nlr57lFfWq NrKHGbz4eaTZHT4Nj70p5wweIKMowItBe+eHzhBno94JDONLyJh5GD/XN09mQdJfzc KgSR4tn7BGUotqIfJqRgmU1GHSnTYtgU/gOiO6Mg1crM/D2phVpQ9XiFxsrIuIt8Lv 2UGSN7qCndYCXGJwILPNDakdjpRTuWNuVQz/vaYqaqzLuEJNLW+vXOoTBW7Peb76yY LUfVBQM5eh1wg== Date: Sat, 28 Nov 2026 23:16:33 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: Lee Jones , Marius Cristea , David Lechner , Nuno =?UTF-8?B?U8Oh?= , Andy Shevchenko , Bogdan Bolocan , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2 4/7] iio: adc: pac1934: Fix custom attribute allocation and channel bounds Message-ID: <20261128231633.36515299@jic23-hlaptop> In-Reply-To: References: <20261123075122.373060-1-lee@kernel.org> <20261123075122.373060-5-lee@kernel.org> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 23 Nov 2026 13:26:24 +0200 Andy Shevchenko wrote: > On Mon, Nov 23, 2026 at 07:50:30AM +0000, Lee Jones wrote: > > pac1934_prep_custom_attributes() sizes the pac1934_custom_attr pointer > > array using sizeof(*pac1934_group) instead of > > sizeof(*pac1934_custom_attr) and adds 1 byte rather than one pointer > > element for the terminating NULL entry. When active_channels_count is > > zero, only a single byte is allocated and iio_device_register_sysfs() > > reads past the allocation when scanning the attribute list. > > > > In addition, active_channels_count is counted over info->phys_channels, > > whereas the population steps unconditionally inspect all four entries of > > info->active_channels[], which can write past the end of the array on > > 1-, 2-, and 3-channel chip variants. > > ... > > > - Order local variables in reverse Christmas tree style (Andy, > > Jonathan) > > Oh, I meant only this for the case when we touch the content. > Since now it's not changed there, no need to do it, probably? > > ... > > > static int pac1934_prep_custom_attributes(struct pac1934_chip_info *info, > > struct iio_dev *indio_dev) > > { > > - int i, active_channels_count = 0; > > + struct device *dev = &info->client->dev; > > struct attribute **pac1934_custom_attr; > > struct attribute_group *pac1934_group; > > - struct device *dev = &info->client->dev; > > + int i, active_channels_count = 0; > > It took me a while to understand why, but no need to resend, if Jonathan is not > okay with that, this hunk may not be applied while the rest is fine. > > TL;DR: > Up to Jonathan (but personally I would leave this as in the original code). > I popped it back whilst applying. Applied to the fixes-togreg branch of iio.git. thanks, Jonathan