2010-11-17 05:11:21

by Dan Carpenter

[permalink] [raw]
Subject: [patch] dca: missing unlock in unregister_dca_providers()

We return here with the lock held and IRQs disabled by mistake.

Signed-off-by: Dan Carpenter <[email protected]>

diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
index b98c676..b4c95be 100644
--- a/drivers/dca/dca-core.c
+++ b/drivers/dca/dca-core.c
@@ -110,8 +110,10 @@ static void unregister_dca_providers(void)

/* at this point only one domain in the list is expected */
domain = list_first_entry(&dca_domains, struct dca_domain, node);
- if (!domain)
+ if (!domain) {
+ spin_unlock_irqrestore(&dca_lock, flags);
return;
+ }

list_for_each_entry_safe(dca, _dca, &domain->dca_providers, node) {
list_del(&dca->node);


2010-11-19 23:00:12

by Andrew Morton

[permalink] [raw]
Subject: Re: [patch] dca: missing unlock in unregister_dca_providers()

On Wed, 17 Nov 2010 08:10:32 +0300
Dan Carpenter <[email protected]> wrote:

> We return here with the lock held and IRQs disabled by mistake.
>
> Signed-off-by: Dan Carpenter <[email protected]>
>
> diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
> index b98c676..b4c95be 100644
> --- a/drivers/dca/dca-core.c
> +++ b/drivers/dca/dca-core.c
> @@ -110,8 +110,10 @@ static void unregister_dca_providers(void)
>
> /* at this point only one domain in the list is expected */
> domain = list_first_entry(&dca_domains, struct dca_domain, node);
> - if (!domain)
> + if (!domain) {
> + spin_unlock_irqrestore(&dca_lock, flags);
> return;
> + }
>
> list_for_each_entry_safe(dca, _dca, &domain->dca_providers, node) {
> list_del(&dca->node);

I think the code's just bogus, actually.
list_first_entry(&dca_domains) can't return NULL.

2010-11-20 18:13:25

by Dan Carpenter

[permalink] [raw]
Subject: [patch v2] dca: remove unneeded NULL check

The return here doesn't release the locks or re-enable IRQs. But as
Andrew Morton points out, domain is never NULL. list_first_entry()
essentially never returns NULL and also we already verified that the
list is not empty.

Signed-off-by: Dan Carpenter <[email protected]>

diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
index b98c676..c461eda 100644
--- a/drivers/dca/dca-core.c
+++ b/drivers/dca/dca-core.c
@@ -110,8 +110,6 @@ static void unregister_dca_providers(void)

/* at this point only one domain in the list is expected */
domain = list_first_entry(&dca_domains, struct dca_domain, node);
- if (!domain)
- return;

list_for_each_entry_safe(dca, _dca, &domain->dca_providers, node) {
list_del(&dca->node);

2010-11-22 16:50:47

by Sosnowski, Maciej

[permalink] [raw]
Subject: RE: [patch v2] dca: remove unneeded NULL check

Dan Carpenter wrote:
> The return here doesn't release the locks or re-enable IRQs. But as
> Andrew Morton points out, domain is never NULL. list_first_entry()
> essentially never returns NULL and also we already verified that the
> list is not empty.
>
> Signed-off-by: Dan Carpenter <[email protected]>
>
> diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c index
> b98c676..c461eda 100644
> --- a/drivers/dca/dca-core.c
> +++ b/drivers/dca/dca-core.c
> @@ -110,8 +110,6 @@ static void unregister_dca_providers(void)
>
> /* at this point only one domain in the list is expected */
> domain = list_first_entry(&dca_domains, struct dca_domain, node);
> - if (!domain)
> - return;
>
> list_for_each_entry_safe(dca, _dca, &domain->dca_providers, node) {
> list_del(&dca->node);

Acked-by: Maciej Sosnowski <[email protected]>