mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "" <pmarques@grupopie.com>
To: Matthew Dharm <mdharm-kernel@one-eyed-alien.net>
Cc: "" <linux-kernel@vger.kernel.org>, "" <perex@suse.cz>,
	"" <luming.yu@intel.com>
Subject: Re: sizeof(ptr) or sizeof(*ptr)?
Date: Sun, 27 Feb 2005 23:13:33 +0000	[thread overview]
Message-ID: <1109546013.4222541d5db16@webmail.grupopie.com> (raw)
In-Reply-To: <20050227204524.GA29026@one-eyed-alien.net>

Quoting Matthew Dharm <mdharm-kernel@one-eyed-alien.net>:
> [...]
> 	us->host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
> 
> This is actually correct as-is.  We're allocating a host, and asking for
> the sizeof(pointer) in the 'extra storage' section.  We then store the
> pointer (not what it points to) in the extra storage section a few lines
> down.

Thanks for clarifying that. I guess the weekend effect got me, because at a
certain point I was starting to read the scsi_host_alloc as if it were a
kmalloc or something... :P

Anyway, after improving the tool and checking for false positives, there is only
one more suspicious piece of code in drivers/acpi/video.c:561

	status = acpi_video_device_lcd_query_levels(device, &obj);

	if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
		int count = 0;
		union acpi_object *o;

		br = kmalloc(sizeof &br, GFP_KERNEL);
		if (!br) {
			printk(KERN_ERR "can't allocate memory\n");
		} else {
			memset(br, 0, sizeof &br);
			br->levels = kmalloc(obj->package.count * sizeof &br->levels, GFP_KERNEL);
			if (!br->levels)
				goto out;

"br" if of type "struct acpi_video_device_brightness *". 

"sizeof &br" doesn't make much sense there (besides the unconventional use of
sizeof without parenthesis) because the rest of the code seem to suggest that a
whole structure should have been allocated. This is the last case I've seen,
and I've added the maintainer to the cc list, so that he can check the code for
correctness.

Well, sorry about bothering you with a false positive (that I should've
recognised on my own, anyway), and thanks for the help.

--
Paulo Marques - www.grupopie.com
 
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)


  reply	other threads:[~2005-02-27 23:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-27 20:25 pmarques
2005-02-27 20:45 ` Matthew Dharm
2005-02-27 23:13   ` pmarques [this message]
2005-02-28  5:39     ` Andrew Morton
2005-03-08 13:20       ` Paulo Marques

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=1109546013.4222541d5db16@webmail.grupopie.com \
    --to=pmarques@grupopie.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luming.yu@intel.com \
    --cc=mdharm-kernel@one-eyed-alien.net \
    --cc=perex@suse.cz \
    /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®