mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH 5/5] gpiolib: gpioinfo: add optional CONTROLLER command line argument
Date: Wed, 28 Sep 2022 16:24:38 +0200	[thread overview]
Message-ID: <20220928142438.GW986@pengutronix.de> (raw)
In-Reply-To: <lyzgejws49.fsf@ensc-pc.intern.sigma-chemnitz.de>

On Wed, Sep 28, 2022 at 03:22:46PM +0200, Enrico Scholz wrote:
> Ahmad Fatoum <a.fatoum@pengutronix.de> writes:
> 
> >  static int do_gpiolib(int argc, char *argv[])
> >  {
> > +	if (argc == 1) {
> > +		dev = find_device(argv[1]);
> 
> 'gpioinfo' without arguments will crash because this calls
> 'find_device(NULL)'
> 
> | :/ gpioinfo 
> | BUG: failure at lib/string.c:226/strcmp()!
> | BUG!

I fixed it with the obvious change

Sascha

----------------------------8<--------------------------

>From 252c76cdf8c9d516589d72ac228ac0d19fcb2021 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Wed, 28 Sep 2022 16:20:48 +0200
Subject: [PATCH] gpiolib: Fix gpioinfo without args

Since a30ae2921a the gpioinfo command crashes when called without
arguments. Fix it by using argv[1] when it actually exists, not when
it doesn't exist.

Fixes: a30ae2921a ("gpiolib: gpioinfo: add optional CONTROLLER command line argument")
Reported-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 7f20709035..2503262d65 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -681,7 +681,7 @@ static int do_gpiolib(int argc, char *argv[])
 	if (argc > 2)
 		return COMMAND_ERROR_USAGE;
 
-	if (argc == 1) {
+	if (argc > 1) {
 		struct device_d *dev;
 
 		dev = find_device(argv[1]);
-- 
2.30.2

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2022-09-28 14:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 10:35 [PATCH 0/5] commands: gpio: add controller as optional argument Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 1/5] gpiolib: implement gpio_get_chip_by_dev() Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 2/5] of: platform: optimize of_find_device_by_node when deep probing Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 3/5] driver: implement find_device() helper Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 4/5] commands: gpio: add -d argument to set/get commands Ahmad Fatoum
2022-09-28 13:37   ` Enrico Scholz
2022-09-28 14:36     ` Sascha Hauer
2022-09-29  9:50     ` Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 5/5] gpiolib: gpioinfo: add optional CONTROLLER command line argument Ahmad Fatoum
2022-09-28 13:22   ` Enrico Scholz
2022-09-28 14:24     ` Sascha Hauer [this message]
2022-09-12  9:13 ` [PATCH 0/5] commands: gpio: add controller as optional argument Sascha Hauer

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=20220928142438.GW986@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=enrico.scholz@sigma-chemnitz.de \
    /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