lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 5 Jul 2007 00:59:12 +0200
From:	Jesper Juhl <jesper.juhl@...il.com>
To:	"Andrew Morton" <akpm@...ux-foundation.org>
Cc:	"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
	"Jaroslav Kysela" <perex@...e.cz>, jesper.juhl@...il.com
Subject: [PATCH][isapnp] Remove pointless check of 'type' against 0 in isapnp_read_tag()

On Wednesday 04 July 2007 03:04:13 Jesper Juhl wrote:
> On 03/07/07, Andrew Morton <akpm@...ux-foundation.org> wrote:
> > On Sun, 1 Jul 2007 01:38:31 +0200
> >
> > Jesper Juhl <jesper.juhl@...il.com> wrote:
> > > The Coverity checker spotted (as bug #809) that we dereference 'type'
> > > long before we actually test it against NULL in
> > > drivers/pnp/isapnp/core.c::isapnp_read_tag() - both branches of the
> > > 'if (tag & 0x80)' dereference type, and since this 'if' is before the
> > > test against NULL and the return of -1, this will blow up is ever type
> > > is NULL. This is easy to fix by simply moving the NULL test to the
> > > beginning of the function.
>
> [snip]
>
> > dood, look at the callers.  NULL is not possible here.
>
> You are right, there's absolutely no way that we could get a NULL
> pointer there - that was sloppy of me :-(
>
> I guess we should just get rid of the check completely.  I'll cook up
> a patch for that tomorrow.

Ok, here's a patch to just remove the check.



In drivers/pnp/isapnp/core.c::isapnp_read_tag() there is a test of 
'type' being == 0 a bit down in the function. That test doesn't make 
any sense. If 'type' could indeed be NULL, then the test happens way 
too late as we'd already have tried to dereference the pointer 
earlier and looking at the callers it also turns out that there is 
no way type can ever actually be NULL.
So the test is completely pointless and should just be removed.


Signed-off-by: Jesper Juhl <jesper.juhl@...il.com>
---

 drivers/pnp/isapnp/core.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index a0b1587..914d00c 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -370,8 +370,6 @@ static int __init isapnp_read_tag(unsigned char *type, unsigned short *size)
 #if 0
 	printk(KERN_DEBUG "tag = 0x%x, type = 0x%x, size = %i\n", tag, *type, *size);
 #endif
-	if (type == 0)				/* wrong type */
-		return -1;
 	if (*type == 0xff && *size == 0xffff)	/* probably invalid data */
 		return -1;
 	return 0;


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ