public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] UBI: Fix potential NULL-pointer dereference
@ 2014-03-28 21:04 Alexander Stein
  2014-03-31  6:18 ` Mats Kärrman
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Stein @ 2014-03-28 21:04 UTC (permalink / raw)
  To: Artem Bityutskiy, David Woodhouse; +Cc: Alexander Stein, linux-mtd

It's no use to debug print a string before checking on NULL.

Signed-off-by: Alexander Stein <alexanders83@web.de>
---
 drivers/mtd/ubi/kapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 3aac1ac..e40864f 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -242,11 +242,11 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
 	struct ubi_device *ubi;
 	struct ubi_volume_desc *ret;
 
-	dbg_gen("open device %d, volume %s, mode %d", ubi_num, name, mode);
-
 	if (!name)
 		return ERR_PTR(-EINVAL);
 
+	dbg_gen("open device %d, volume %s, mode %d", ubi_num, name, mode);
+
 	len = strnlen(name, UBI_VOL_NAME_MAX + 1);
 	if (len > UBI_VOL_NAME_MAX)
 		return ERR_PTR(-EINVAL);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] UBI: Fix potential NULL-pointer dereference
  2014-03-28 21:04 [PATCH] UBI: Fix potential NULL-pointer dereference Alexander Stein
@ 2014-03-31  6:18 ` Mats Kärrman
  2014-03-31  9:46   ` Artem Bityutskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Mats Kärrman @ 2014-03-31  6:18 UTC (permalink / raw)
  To: Alexander Stein, Artem Bityutskiy, David Woodhouse
  Cc: linux-mtd@lists.infradead.org

On Friday, March 28, 2014 10:04 PM, Alexander Stein wrote:
>
> It's no use to debug print a string before checking on NULL.
>

If the string is NULL, that could be very useful to know when debugging and
the print function should handle that gracefully, i.e. by not printing anything
for %s.

BR // Mats

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] UBI: Fix potential NULL-pointer dereference
  2014-03-31  6:18 ` Mats Kärrman
@ 2014-03-31  9:46   ` Artem Bityutskiy
  2014-03-31 17:00     ` Alexander Stein
  0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2014-03-31  9:46 UTC (permalink / raw)
  To: Mats Kärrman
  Cc: Alexander Stein, linux-mtd@lists.infradead.org, David Woodhouse

On Mon, 2014-03-31 at 06:18 +0000, Mats Kärrman wrote:
> On Friday, March 28, 2014 10:04 PM, Alexander Stein wrote:
> >
> > It's no use to debug print a string before checking on NULL.
> >
> 
> If the string is NULL, that could be very useful to know when debugging and
> the print function should handle that gracefully, i.e. by not printing anything
> for %s.

%s will just result in (null), I do not see any issue with this.

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] UBI: Fix potential NULL-pointer dereference
  2014-03-31  9:46   ` Artem Bityutskiy
@ 2014-03-31 17:00     ` Alexander Stein
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Stein @ 2014-03-31 17:00 UTC (permalink / raw)
  To: dedekind1
  Cc: linux-mtd@lists.infradead.org, David Woodhouse, Mats Kärrman

On Monday 31 March 2014, 12:46:40 wrote Artem Bityutskiy:
> On Mon, 2014-03-31 at 06:18 +0000, Mats Kärrman wrote:
> > On Friday, March 28, 2014 10:04 PM, Alexander Stein wrote:
> > >
> > > It's no use to debug print a string before checking on NULL.
> > >
> > 
> > If the string is NULL, that could be very useful to know when debugging and
> > the print function should handle that gracefully, i.e. by not printing anything
> > for %s.
> 
> %s will just result in (null), I do not see any issue with this.

Oh, it does? I was not aware of that (kernel-specific) behavior.
Sorry for ne noise.

Best regards,
Alexander

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-31 17:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-28 21:04 [PATCH] UBI: Fix potential NULL-pointer dereference Alexander Stein
2014-03-31  6:18 ` Mats Kärrman
2014-03-31  9:46   ` Artem Bityutskiy
2014-03-31 17:00     ` Alexander Stein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox