public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* re: pstore/ram: Add ftrace messages handling
@ 2012-07-19 14:28 Dan Carpenter
  2012-07-19 23:20 ` Anton Vorontsov
  2012-07-19 23:43 ` [PATCH] pstore/ram: Fix possible NULL dereference Anton Vorontsov
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-07-19 14:28 UTC (permalink / raw)
  To: anton.vorontsov; +Cc: linux-kernel, devel

Hello Anton Vorontsov,

This is a semi-automatic email about new static checker warnings.

The patch a694d1b5916a: "pstore/ram: Add ftrace messages handling" 
from Jul 9, 2012, leads to the following Smatch complaint:

fs/pstore/ram.c:423 ramoops_probe()
	 error: we previously assumed 'cxt->cprz' could be null (see line 408)

fs/pstore/ram.c
   407	
   408		if (!cxt->przs && !cxt->cprz && !cxt->fprz) {
                                  ^^^^^^^^^^

Checked here.

   409			pr_err("memory size too small, minimum is %lu\n",
   410				cxt->console_size + cxt->record_size +
   411				cxt->ftrace_size);
   412			goto fail_cnt;
   413		}
   414	
   415		cxt->pstore.data = cxt;
   416		/*
   417		 * Console can handle any buffer size, so prefer dumps buffer
   418		 * size since usually it is smaller.
   419		 */
   420		if (cxt->przs)
   421			cxt->pstore.bufsize = cxt->przs[0]->buffer_size;
   422		else
   423			cxt->pstore.bufsize = cxt->cprz->buffer_size;
                                              ^^^^^^^^^
Dereferenced here.  What about if only "cxt->fprz" is non-NULL?

Also these are crap variable names, "przs" and "cprz" look so similar.
It makes my head hurt to keep them appart.

   424		cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);
   425		spin_lock_init(&cxt->pstore.buf_lock);

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-07-20 16:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-19 14:28 pstore/ram: Add ftrace messages handling Dan Carpenter
2012-07-19 23:20 ` Anton Vorontsov
2012-07-20  6:43   ` Dan Carpenter
2012-07-19 23:43 ` [PATCH] pstore/ram: Fix possible NULL dereference Anton Vorontsov
2012-07-20 16:31   ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox