* [PATCH] checkpatch: fix false positives for IIO_DEV_ATTR permission checks
@ 2026-05-04 9:23 Angus Gardner
0 siblings, 0 replies; 3+ messages in thread
From: Angus Gardner @ 2026-05-04 9:23 UTC (permalink / raw)
To: linux-kernel; +Cc: apw, joe, dwaipayanray1, lukas.bulwahn
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:
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
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.
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.
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.
Signed-off-by: Angus Gardner <angusg778@gmail.com>
---
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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 = (
["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],
+ ["IIO_DEV_ATTR_(?!(?:FREQ|PHASE|OUTY_ENABLE|OUT_WAVETYPE))[A-Z_]+", 2],
["SENSOR_(?:DEVICE_|)ATTR_2", 2],
["SENSOR_TEMPLATE(?:_2|)", 3],
["__ATTR", 2],
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] checkpatch: fix false positives for IIO_DEV_ATTR permission checks
@ 2026-05-03 4:11 Angus Gardner
2026-05-03 4:56 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Angus Gardner @ 2026-05-03 4:11 UTC (permalink / raw)
To: linux-kernel; +Cc: apw, joe, dwaipayanray1, lukas.bulwahn
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:
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
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.
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.
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.
Signed-off-by: Angus Gardner <angusg778@gmail.com>
---
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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 = (
["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],
+ ["IIO_DEV_ATTR_(?!(?:FREQ|PHASE|OUTY_ENABLE|OUT_WAVETYPE))[A-Z_]+", 2],
["SENSOR_(?:DEVICE_|)ATTR_2", 2],
["SENSOR_TEMPLATE(?:_2|)", 3],
["__ATTR", 2],
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] checkpatch: fix false positives for IIO_DEV_ATTR permission checks
2026-05-03 4:11 Angus Gardner
@ 2026-05-03 4:56 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2026-05-03 4:56 UTC (permalink / raw)
To: Angus Gardner, linux-kernel; +Cc: apw, dwaipayanray1, lukas.bulwahn
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:
>
> 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
>
> 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.
>
> 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.
>
> 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.
>
> Signed-off-by: Angus Gardner <[angusg778@gmail.com](mailto:angusg778@gmail.com)>
> ---
> scripts/checkpatch.pl | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> 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 = (
> ["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],
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-04 9:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 9:23 [PATCH] checkpatch: fix false positives for IIO_DEV_ATTR permission checks Angus Gardner
-- strict thread matches above, loose matches on Subject: below --
2026-05-03 4:11 Angus Gardner
2026-05-03 4:56 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox