mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@turbolinux.com>
To: Jeff Garzik <jgarzik@mandrakesoft.com>
Cc: Junfeng Yang <yjf@stanford.edu>,
	linux-kernel@vger.kernel.org, mc@cs.stanford.edu,
	Andrew Morton <andrewm@uow.edu.au>,
	netdev@oss.sgi.com, dahinds@users.sourceforge.net
Subject: Re: [CHECKER] 120 potential dereference to invalid pointers errors  forlinux 2.4.1
Date: Mon, 19 Mar 2001 09:24:48 -0700 (MST)	[thread overview]
Message-ID: <200103191624.f2JGOmo16559@webber.adilger.int> (raw)
In-Reply-To: <3AB49C2E.4792071B@mandrakesoft.com> from Jeff Garzik at "Mar 18, 2001 06:29:50 am"

Jeff Garzic writes:
> > [BUG] init_etherdev could return NULL
> > /u2/acc/oses/linux/2.4.1/drivers/net/3c515.c:604:corkscrew_found_device: ERROR:NULL:603:604: Using unknown ptr "dev" illegally! set by 'init_etherdev':603
> > 
> > Start --->
> >         dev = init_etherdev(dev, sizeof(struct corkscrew_private));
> > Error --->
> >         dev->base_addr = ioaddr;
> >         dev->irq = irq;
> 
> init_etherdev is a special case -- It can conditionally take NULL as its
> first argument.  If that is the case, when an allocation is performed,
> and the return val needed to be checked for NULL.  If init_etherdev's
> first arg is guaranteed to be non-NULL, you do not need to check its
> return value.  3c515 is one such case.

If this is the case, why not change it to look like:

	init_etherdev(dev, sizeof(struct corkscrew_private));

so it doesn't appear that you are setting "dev" again?

> >         dev = init_trdev(dev,0);

Ditto, don't make it look like "dev" is getting set on the return value,
when it is already set when calling the function.

> > /u2/acc/oses/linux/2.4.1/drivers/pcmcia/bulkmem.c:231:setup_erase_request: ERROR:NULL:230:231: Using unknown ptr "busy" illegally! set by 'kmalloc':230
> > 
> > Start --->
> >             busy = kmalloc(sizeof(erase_busy_t), GFP_KERNEL);
> > Error --->
> 
> This sizeof() construct may be a special case for your checker, but it's
> a common one for the kernel...  It definitely doesn't de-reference a
> pointer.

It is the "busy" pointer that appears to be dereferenced, not the sizeof.
We need something like (ERASE_BAD_KMALLOC doesn't yet exist):

	else if ((busy = kmalloc(sizeof(erase_busy_t), GFP_KERNEL)) == NULL)
		erase->State = ERASE_BAD_KMALLOC;
	else {
		erase->State = 1;
		...
	}

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

  parent reply	other threads:[~2001-03-19 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-17  9:30 [CHECKER] 120 potential dereference to invalid pointers errors for linux 2.4.1 Junfeng Yang
2001-03-17 12:31 ` Mitchell Blank Jr
2001-03-17 19:02   ` Andy Chou
2001-03-17 21:43 ` Greg KH
2001-03-18 11:29 ` [CHECKER] 120 potential dereference to invalid pointers errors forlinux 2.4.1 Jeff Garzik
2001-03-18 12:16   ` Keith Owens
2001-03-19 16:24   ` Andreas Dilger [this message]
2001-03-21 19:35     ` [CHECKER] 120 potential dereference to invalid pointers errors Benjamin Chelf

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=200103191624.f2JGOmo16559@webber.adilger.int \
    --to=adilger@turbolinux.com \
    --cc=andrewm@uow.edu.au \
    --cc=dahinds@users.sourceforge.net \
    --cc=jgarzik@mandrakesoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mc@cs.stanford.edu \
    --cc=netdev@oss.sgi.com \
    --cc=yjf@stanford.edu \
    /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®