mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Strakh <strakh@ispras.ru>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Adam Belay <abelay@mit.edu>, Bjorn Helgaas <bjorn.helgaas@hp.com>,
	linux-kernel@vger.kernel.org
Subject: BUG mutex_unlock without mutex_lock in drivers/pnp/isapnp/core.c
Date: Mon, 1 Mar 2010 15:59:40 +0000	[thread overview]
Message-ID: <201003011559.40139.strakh@ispras.ru> (raw)

	KERNEL_VERSION: 2.6.33
	SUBJECT: mutex_unlock without mutex_lock
	DESCRIBE:
	In drivers/pnp/isapnp/core.c in function isapnp_get_resources:

 1. In line 906 we call isapnp_cfg_begin(dev->card->number, dev->number);

 900 static int isapnp_get_resources(struct pnp_dev *dev)
 901 {
 902         int i, ret;
 903
 904         pnp_dbg(&dev->dev, "get resources\n");
 905         pnp_init_resources(dev);
 906         isapnp_cfg_begin(dev->card->number, dev->number);
...

2. If csn<1 or csn > isapnp_csn_count or logdev > 10 then function returns -
EINVAL and does not call mutex_lock.

 856 int isapnp_cfg_begin(int csn, int logdev)
 857 {
 858         if (csn < 1 || csn > isapnp_csn_count || logdev > 10)
 859                 return -EINVAL;
 860         mutex_lock(&isapnp_cfg_mutex);
...

3. Suppose function isapnp_read_bytes returned a null value. In this case we 
goto line 932 and call isapnp_cfg_end.

 907         dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
 908         if (!dev->active)
 909                 goto __end;
...
 932 __end:
 933         isapnp_cfg_end();
 934         return 0;
 935 }

4. isapnp_cfg_end in line  886 calls mutex_unlock on &isapnp_cfg_mutex without 
mutex_lock (it was not locked in function isapnp_cfg_begin because of -
EINVAL).

 883 int isapnp_cfg_end(void)
 884 {
 885         isapnp_wait();
 886         mutex_unlock(&isapnp_cfg_mutex);
 887         return 0;
 888 }

Found by Linux Device Drivers Verification Project

             reply	other threads:[~2010-03-01 13:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-01 15:59 Alexander Strakh [this message]
2010-03-02 22:34 ` Bjorn Helgaas

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=201003011559.40139.strakh@ispras.ru \
    --to=strakh@ispras.ru \
    --cc=abelay@mit.edu \
    --cc=bjorn.helgaas@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    /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

all inboxes | Powered by JetHome®