From: Hangbin Liu <hangbin.liu@linux.dev>
To: Zhiqi Zhang <zhiqizhangg@gmail.com>
Cc: Donald Hunter <donald.hunter@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] tools: ynl: reject missing regen path argument
Date: Thu, 26 Nov 2026 17:23:37 +0800 [thread overview]
Message-ID: <20261126092337.GJ33976@Liu-laptop> (raw)
In-Reply-To: <20261125070354.18200-1-zhiqizhangg@gmail.com>
On Wed, Nov 25, 2026 at 03:03:54PM +0800, Zhiqi Zhang wrote:
> ynl-regen.sh expects -p to be followed by a path. If -p is
> passed without an argument, $2 is empty and shift 2 fails without
> consuming $1. The option parser then keeps looping on -p until
> the caller kills the script.
>
> I found the issue by manual code inspection and validated it with:
>
> timeout 2s bash tools/net/ynl/ynl-regen.sh -p
>
> which used to time out with exit code 124.
>
> Reject -p without an argument before shifting. Also stop if the
> selected path cannot be entered, so the script does not continue
> from an unintended directory after a bad -p path.
>
> GPT wrote the code change; I reviewed and tested it.
>
> Tested with:
>
> timeout 2s bash tools/net/ynl/ynl-regen.sh -p
> timeout 2s bash tools/net/ynl/ynl-regen.sh -p \
> /definitely/not/a/kernel/tree
> bash -n tools/net/ynl/ynl-regen.sh
> scripts/checkpatch.pl --strict --file tools/net/ynl/ynl-regen.sh
>
> Fixes: 25b5a2a1905f ("ynl: regenerate all headers")
> Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
> ---
> tools/net/ynl/ynl-regen.sh | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tools/net/ynl/ynl-regen.sh b/tools/net/ynl/ynl-regen.sh
> index d9809276db..524fadb770 100755
> --- a/tools/net/ynl/ynl-regen.sh
> +++ b/tools/net/ynl/ynl-regen.sh
> @@ -9,13 +9,20 @@ search=
> while [ ! -z "$1" ]; do
> case "$1" in
> -f ) force=yes; shift ;;
> - -p ) search=$2; shift 2 ;;
> + -p )
> + if [ $# -lt 2 ]; then
> + echo "Option -p requires a path" >&2
> + exit 1
> + fi
> + search=$2
> + shift 2
> + ;;
> * ) echo "Unrecognized option '$1'"; exit 1 ;;
> esac
> done
>
> KDIR=$(dirname $(dirname $(dirname $(dirname $(realpath $0)))))
> -pushd ${search:-$KDIR} >>/dev/null
> +pushd "${search:-$KDIR}" >>/dev/null || exit 1
>
> files=$(git grep --files-with-matches '^/\* YNL-GEN \(kernel\|uapi\|user\)')
> for f in $files; do
>
> base-commit: 7ccb044c27720d48175577080b851f047ddcfd1c
> --
> 2.54.0 (Apple Git-157)
>
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
prev parent reply other threads:[~2026-11-26 9:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 7:03 Zhiqi Zhang
2026-11-26 9:23 ` Hangbin Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126092337.GJ33976@Liu-laptop \
--to=hangbin.liu@linux.dev \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=zhiqizhangg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®