From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 066E040DFD9 for ; Sun, 3 May 2026 04:56:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777784221; cv=none; b=nTDFMw49yoYbJPalWM/GJfvxTauWyBlnOvXbfxJXA9CYE7snMJA5bT1VjNlNoE8+0pLEHBAI1nI084SssXSHnff+PuZRGoORRPxnTWdSc30b4ciA64LmTKRZPQo98sdaNdFrvYJpUwwCShrE+tojd2K3OKFER3Iag2iFgcbmYG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777784221; c=relaxed/simple; bh=ka6KqcQZMktVgeKF80I6r34YgS3Idtmg0V94+jbM9ZE=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=FQudMBTP+EiLAb/I9OqNne5Vht0jq1fixFBKFI2l3rYFpr2j6PcePBy+kImZILUBCrBf0Av7KSL4QB9VDzAagEKjRPPLx2BmhwlGs4zcAsGHtmOrEuLPwlxwDyTWee6k9O60sXKow2l9gxtlWvfElpYPYonCrU0d7u5xRLSBp88= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf12.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id ED934C2850; Sun, 3 May 2026 04:56:52 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA id E99A818; Sun, 3 May 2026 04:56:50 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: fix false positives for IIO_DEV_ATTR permission checks From: Joe Perches To: Angus Gardner , linux-kernel@vger.kernel.org Cc: apw@canonical.com, dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com Date: Sat, 02 May 2026 21:56:49 -0700 In-Reply-To: <20260503041120.528859-1-angusg778@gmail.com> References: <20260503041120.528859-1-angusg778@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: E99A818 X-Stat-Signature: s1pcpf1nz551j1i84td91jy7bb6e68bk X-Rspamd-Server: rspamout01 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/etDd0J+y2MZu0VqBQiVwIDDxgLVNGv3g= X-HE-Tag: 1777784210-692350 X-HE-Meta: U2FsdGVkX19jorJCmrwL6Y9uR9lCldpzv+JJuueDetDR+34kdIg0GS1nj2B2IFfUJ8KZQRAlz61Uevs+gv9zfj2tZvTJg39xUeWGqRbp566XDW3/T/jvXMcsWqtM0GPirdfkc1w9vlTxqOy3jhLQBAFXJoUWfYidprnJ0Dgy3dtmfFk64TfndzlbJmyT1O+Dyos82MPmMpJq58zPOcVRNgO+PaVwOiZldvyrJstO7wV7Eor8FtxD4IYKjBbJEdycaKmPUjp71ApYOAB8OZRCfhq/TX74/FNK5evdbbDvq8bsQtBcq4Ekiln5I3grHddMITMZjoOz6xH01hz5s6Z3Q9Ce72ZHTOWA On Sun, 2026-05-03 at 14:11 +1000, Angus Gardner wrote: > ``` > The IIO_DEV_ATTR_[A-Z_]+ entry in @mode_permission_funcs used argument > position 1 for all IIO_DEV_ATTR_* macros, but this is incorrect for > several variants that take an extra numeric argument before the mode: >=20 > IIO_DEV_ATTR_FREQ(channel, num, mode, ...) - mode at position 3 > IIO_DEV_ATTR_PHASE(channel, num, mode, ...) - mode at position 3 > IIO_DEV_ATTR_OUTY_ENABLE(channel, out, mode, ..) - mode at position 3 >=20 > With position 1, checkpatch checked the channel argument (always 0) > or the numeric _num/_output argument (0, 1, 2, 3) instead of the actual > permission, producing spurious NON_OCTAL_PERMISSIONS errors. >=20 > IIO_DEV_ATTR_OUT_WAVETYPE has no permission argument at all (it is > hardcoded as 0200 inside the macro), so it should be excluded from > permission checking entirely. >=20 > Fix by splitting the single entry into two: one matching the three- > argument variants at position 3, using a negative lookahead to prevent > overlap with the second entry which matches the remaining IIO_DEV_ATTR_* > macros (including OUT_WAVETYPE exclusion) at the correct position 2. >=20 > Signed-off-by: Angus Gardner <[angusg778@gmail.com](mailto:angusg778@gmai= l.com)> > --- > scripts/checkpatch.pl | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 0492d6afc..fa2af8527 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -840,7 +840,8 @@ our @mode_permission_funcs =3D ( > ["debugfs_create_(?:file|u8|u16|u32|u64|x8|x16|x32|x64|size_t|atomic_t|= bool|blob|regset32|u32_array)", 2], > ["proc_create(?:_data|)", 2], > ["(?:CLASS|DEVICE|SENSOR|SENSOR_DEVICE|IIO_DEVICE)_ATTR", 2], > - ["IIO_DEV_ATTR_[A-Z_]+", 1], > + ["IIO_DEV_ATTR_(?:FREQ|PHASE|OUTY_ENABLE)[A-Z_]*", 3], This is not correct. IIO_DEV_ATTR_FREQSYMBOL and IIO_DEV_ATTR_PHASESYMBOL use permissions at parameter 2 Better would be ["IIO_DEV_ATTR_(?:FREQ|PHASE|OUTY_ENABLE)", 3], as the trailing [A-Z_]* is unnecessary. But it's probably better to remove IIO_DEV_ATTR line altogether as it's mostly not used except in staging. $ git grep IIO_DEV_ATTR_ | cut -f1,2 -d/ | uniq -c 20 drivers/iio 31 drivers/staging 8 include/linux 1 scripts/checkpatch.pl: ["IIO_DEV_ATTR_[A-Z_]+", 1],