public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Owens <kaos@ocs.com.au>
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
Subject: Re: [CHECKER] 120 potential dereference to invalid pointers errors forlinux 2.4.1
Date: Sun, 18 Mar 2001 23:16:16 +1100	[thread overview]
Message-ID: <24784.984917776@ocs3.ocs-net> (raw)
In-Reply-To: Your message of "Sun, 18 Mar 2001 06:29:50 CDT." <3AB49C2E.4792071B@mandrakesoft.com>

On Sun, 18 Mar 2001 06:29:50 -0500, 
Jeff Garzik <jgarzik@mandrakesoft.com> wrote:
>Junfeng Yang wrote:
>> 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.

IMHO the above line is a bad construct.  If the type of the variable
changes it is extremely easy to miss the fact that *alloc is now
returning the wrong size.  I always do

	busy = kmalloc(sizeof(*busy), GFP_KERNEL);

and let the compiler insert the correct type.

For the checker, you can also have typeof().  kdb has this line

	typeof (*ef)    local_ef;

The type definition of ef is kdb_eframe_t which is "pointer to some
arch dependent type" and local_ef is in arch independent code, much
easier to do this than use multiple #ifdef.  Of course it would have
been even easier if kdb had separate types for the struct and the
pointer to the struct, then I would not need typeof().  OTOH I am sure
that somebody will find a use for typeof().


  reply	other threads:[~2001-03-18 12:17 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 [this message]
2001-03-19 16:24   ` Andreas Dilger
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=24784.984917776@ocs3.ocs-net \
    --to=kaos@ocs.com.au \
    --cc=andrewm@uow.edu.au \
    --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