Linux I2C development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: re: i2c: pxa: add OF support
Date: Wed, 6 Nov 2013 19:12:17 +0300	[thread overview]
Message-ID: <20131106161217.GB15603@elgon.mountain> (raw)

Hello Haojian Zhuang,

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

The patch 63fe122bce06: "i2c: pxa: add OF support" from Mar 1, 2012, 
leads to the following Smatch complaint:

drivers/i2c/busses/i2c-pxa.c:1272 i2c_pxa_probe()
	 error: we previously assumed 'res' could be null (see line 1161)

drivers/i2c/busses/i2c-pxa.c
  1160		irq = platform_get_irq(dev, 0);
  1161		if (res == NULL || irq < 0) {
                    ^^^^^^^^^^^
Patch introduces a new error path.

  1162			ret = -ENODEV;
  1163			goto eclk;
  1164		}
  1165	

[snip]

  1267  eremap:
  1268          clk_put(i2c->clk);
  1269  eclk:
  1270          kfree(i2c);
  1271	emalloc:
  1272		release_mem_region(res->start, resource_size(res));
                                   ^^^^^^^^^^  ^^^^^^^^^^^^^^^^^
Null dereferences.

Obviously the unwind needs to be fixed so it's a mirror reflection of
the allocation order.  Also the labels are crap.  Label names should be
based on the label location and not the goto location(s).

  1273		return ret;
  1274	}

regards,
dan carpenter

                 reply	other threads:[~2013-11-06 16:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20131106161217.GB15603@elgon.mountain \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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