linux-btrace.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: linux-btrace@vger.kernel.org
Subject: Re: blktrace segfault.
Date: Wed, 14 Nov 2007 09:53:01 +0000	[thread overview]
Message-ID: <20071114095300.GC26602@kernel.dk> (raw)
In-Reply-To: <4724673E.1090404@linux.vnet.ibm.com>

On Wed, Nov 14 2007, Christoph Hellwig wrote:
> On Wed, Nov 14, 2007 at 10:45:30AM +0100, Jens Axboe wrote:
> > > > 	size = ncpus * sizeof(struct thread_information);
> > > > 	thread_information = malloc(size * ndevs);
> > > > +	memset(thread_information, 0, size*ndevs);
> > > > 	if (!thread_information) {
> > > > 		fprintf(stderr, "Out of memory, threads (%d)\n", size * ndevs);
> > > > 		return 1;
> > > 
> > > I'm pretty sure you want to make the memset after the NULL-pointer check. If
> > > malloc fails this is segfaulting too.
> > 
> > Ehm that's indeed a good point, I'll check in a fix for that.
> 
> Even better just use calloc..

I considered it, but it holds ndevs * ncpus * size, so I thought it was
cleaner to keep it as-is and just move the memset.

-- 
Jens Axboe


      parent reply	other threads:[~2007-11-14  9:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-28 10:53 blktrace segfault Aneesh Kumar K.V
2007-10-29 19:47 ` Jens Axboe
2007-11-14  9:39 ` Jan Blunck
2007-11-14  9:45 ` Jens Axboe
2007-11-14  9:51 ` Christoph Hellwig
2007-11-14  9:53 ` Jens Axboe [this message]

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=20071114095300.GC26602@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=linux-btrace@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).