All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: anton.vorontsov@linaro.org
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Subject: re: pstore/ram: Add ftrace messages handling
Date: Thu, 19 Jul 2012 17:28:56 +0300	[thread overview]
Message-ID: <20120719142856.GA25184@elgon.mountain> (raw)

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


             reply	other threads:[~2012-07-19 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 14:28 Dan Carpenter [this message]
2012-07-19 23:20 ` pstore/ram: Add ftrace messages handling 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

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=20120719142856.GA25184@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=anton.vorontsov@linaro.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.