* [PATCH] ISAPNP: don't unlock isapnp_cfg_mutex unless we've locked it first
@ 2010-03-02 22:36 Bjorn Helgaas
2010-03-03 6:48 ` Jaroslav Kysela
0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Helgaas @ 2010-03-02 22:36 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, Alexander Strakh, Adam Belay, Jaroslav Kysela
If isapnp_cfg_begin() fails, it returns without locking isapnp_cfg_mutex.
Previously, we always unlocked the mutex, even if we haven't locked it
first.
This patch checks the isapnp_cfg_begin() return value so we can just
exit and avoid this locking error.
Found by the Linux Device Drivers Verification Project and reported by
Alexander Strakh <strakh@ispras.ru>.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
drivers/pnp/isapnp/core.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index e851160..93e95ad 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -903,7 +903,10 @@ static int isapnp_get_resources(struct pnp_dev *dev)
pnp_dbg(&dev->dev, "get resources\n");
pnp_init_resources(dev);
- isapnp_cfg_begin(dev->card->number, dev->number);
+ ret = isapnp_cfg_begin(dev->card->number, dev->number);
+ if (ret)
+ return ret;
+
dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
if (!dev->active)
goto __end;
@@ -937,10 +940,13 @@ __end:
static int isapnp_set_resources(struct pnp_dev *dev)
{
struct resource *res;
- int tmp;
+ int tmp, ret;
pnp_dbg(&dev->dev, "set resources\n");
- isapnp_cfg_begin(dev->card->number, dev->number);
+ ret = isapnp_cfg_begin(dev->card->number, dev->number);
+ if (ret)
+ return ret;
+
dev->active = 1;
for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_IO, tmp);
@@ -986,9 +992,13 @@ static int isapnp_set_resources(struct pnp_dev *dev)
static int isapnp_disable_resources(struct pnp_dev *dev)
{
+ int ret;
+
if (!dev->active)
return -EINVAL;
- isapnp_cfg_begin(dev->card->number, dev->number);
+ ret = isapnp_cfg_begin(dev->card->number, dev->number);
+ if (ret)
+ return ret;
isapnp_deactivate(dev->number);
dev->active = 0;
isapnp_cfg_end();
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ISAPNP: don't unlock isapnp_cfg_mutex unless we've locked it first
2010-03-02 22:36 [PATCH] ISAPNP: don't unlock isapnp_cfg_mutex unless we've locked it first Bjorn Helgaas
@ 2010-03-03 6:48 ` Jaroslav Kysela
0 siblings, 0 replies; 2+ messages in thread
From: Jaroslav Kysela @ 2010-03-03 6:48 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Len Brown, linux-acpi, Alexander Strakh, Adam Belay
On Tue, 2 Mar 2010, Bjorn Helgaas wrote:
>
> If isapnp_cfg_begin() fails, it returns without locking isapnp_cfg_mutex.
> Previously, we always unlocked the mutex, even if we haven't locked it
> first.
>
> This patch checks the isapnp_cfg_begin() return value so we can just
> exit and avoid this locking error.
>
> Found by the Linux Device Drivers Verification Project and reported by
> Alexander Strakh <strakh@ispras.ru>.
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-03-03 7:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-02 22:36 [PATCH] ISAPNP: don't unlock isapnp_cfg_mutex unless we've locked it first Bjorn Helgaas
2010-03-03 6:48 ` Jaroslav Kysela
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox