Re: blktrace segfault.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-
To unsubscribe from this list: send the line "unsubscribe linux-btrace" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux