* [PATCH 1/3] soc: ti: Use list_first_entry_or_null() at appropriate places
@ 2014-10-26 9:37 ` Axel Lin
0 siblings, 0 replies; 8+ messages in thread
From: Axel Lin @ 2014-10-26 9:37 UTC (permalink / raw)
To: Santosh Shilimkar; +Cc: Sandeep Nair, linux-kernel, linux-arm-kernel
Use list_first_entry_or_null() for first_region() and first_queue_range().
list_first_entry() expects the list is not empty, so first_region() and
first_queue_range() never return NULL.
Thus use list_first_entry_or_null() instead.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/soc/ti/knav_qmss.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
index bc9dcc8..51da234 100644
--- a/drivers/soc/ti/knav_qmss.h
+++ b/drivers/soc/ti/knav_qmss.h
@@ -348,15 +348,15 @@ struct knav_range_info {
list_for_each_entry(region, &kdev->regions, list)
#define first_region(kdev) \
- list_first_entry(&kdev->regions, \
- struct knav_region, list)
+ list_first_entry_or_null(&kdev->regions, \
+ struct knav_region, list)
#define for_each_queue_range(kdev, range) \
list_for_each_entry(range, &kdev->queue_ranges, list)
#define first_queue_range(kdev) \
- list_first_entry(&kdev->queue_ranges, \
- struct knav_range_info, list)
+ list_first_entry_or_null(&kdev->queue_ranges, \
+ struct knav_range_info, list)
#define for_each_pool(kdev, pool) \
list_for_each_entry(pool, &kdev->pools, list)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/3] soc: ti: Use list_first_entry_or_null() at appropriate places
@ 2014-10-26 9:37 ` Axel Lin
0 siblings, 0 replies; 8+ messages in thread
From: Axel Lin @ 2014-10-26 9:37 UTC (permalink / raw)
To: linux-arm-kernel
Use list_first_entry_or_null() for first_region() and first_queue_range().
list_first_entry() expects the list is not empty, so first_region() and
first_queue_range() never return NULL.
Thus use list_first_entry_or_null() instead.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/soc/ti/knav_qmss.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
index bc9dcc8..51da234 100644
--- a/drivers/soc/ti/knav_qmss.h
+++ b/drivers/soc/ti/knav_qmss.h
@@ -348,15 +348,15 @@ struct knav_range_info {
list_for_each_entry(region, &kdev->regions, list)
#define first_region(kdev) \
- list_first_entry(&kdev->regions, \
- struct knav_region, list)
+ list_first_entry_or_null(&kdev->regions, \
+ struct knav_region, list)
#define for_each_queue_range(kdev, range) \
list_for_each_entry(range, &kdev->queue_ranges, list)
#define first_queue_range(kdev) \
- list_first_entry(&kdev->queue_ranges, \
- struct knav_range_info, list)
+ list_first_entry_or_null(&kdev->queue_ranges, \
+ struct knav_range_info, list)
#define for_each_pool(kdev, pool) \
list_for_each_entry(pool, &kdev->pools, list)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] soc: ti: knav_qmss_queue: Fix unbalanced locking in knav_pool_create()
2014-10-26 9:37 ` Axel Lin
@ 2014-10-26 9:38 ` Axel Lin
-1 siblings, 0 replies; 8+ messages in thread
From: Axel Lin @ 2014-10-26 9:38 UTC (permalink / raw)
To: Santosh Shilimkar; +Cc: Sandeep Nair, linux-kernel, linux-arm-kernel
Don't call mutex_unlock() in the error patch if the mutex_lock() is not called.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/soc/ti/knav_qmss_queue.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 0a2c863..d66aaf2 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -785,7 +785,7 @@ void *knav_pool_create(const char *name,
dev_err(kdev->dev, "out of descs in region(%d) for pool(%s)\n",
region_id, name);
ret = -ENOMEM;
- goto err;
+ goto err_unlock;
}
/* Region maintains a sorted (by region offset) list of pools
@@ -815,15 +815,16 @@ void *knav_pool_create(const char *name,
dev_err(kdev->dev, "pool(%s) create failed: fragmented desc pool in region(%d)\n",
name, region_id);
ret = -ENOMEM;
- goto err;
+ goto err_unlock;
}
mutex_unlock(&knav_dev_lock);
kdesc_fill_pool(pool);
return pool;
-err:
+err_unlock:
mutex_unlock(&knav_dev_lock);
+err:
kfree(pool->name);
devm_kfree(kdev->dev, pool);
return ERR_PTR(ret);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] soc: ti: knav_qmss_queue: Fix unbalanced locking in knav_pool_create()
@ 2014-10-26 9:38 ` Axel Lin
0 siblings, 0 replies; 8+ messages in thread
From: Axel Lin @ 2014-10-26 9:38 UTC (permalink / raw)
To: linux-arm-kernel
Don't call mutex_unlock() in the error patch if the mutex_lock() is not called.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/soc/ti/knav_qmss_queue.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 0a2c863..d66aaf2 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -785,7 +785,7 @@ void *knav_pool_create(const char *name,
dev_err(kdev->dev, "out of descs in region(%d) for pool(%s)\n",
region_id, name);
ret = -ENOMEM;
- goto err;
+ goto err_unlock;
}
/* Region maintains a sorted (by region offset) list of pools
@@ -815,15 +815,16 @@ void *knav_pool_create(const char *name,
dev_err(kdev->dev, "pool(%s) create failed: fragmented desc pool in region(%d)\n",
name, region_id);
ret = -ENOMEM;
- goto err;
+ goto err_unlock;
}
mutex_unlock(&knav_dev_lock);
kdesc_fill_pool(pool);
return pool;
-err:
+err_unlock:
mutex_unlock(&knav_dev_lock);
+err:
kfree(pool->name);
devm_kfree(kdev->dev, pool);
return ERR_PTR(ret);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] soc: ti: knav_qmss_queue: Return proper error if devm_kzalloc fails
2014-10-26 9:37 ` Axel Lin
@ 2014-10-26 9:39 ` Axel Lin
-1 siblings, 0 replies; 8+ messages in thread
From: Axel Lin @ 2014-10-26 9:39 UTC (permalink / raw)
To: Santosh Shilimkar; +Cc: Sandeep Nair, linux-kernel, linux-arm-kernel
Return -ENOMEM if devm_kzalloc fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/soc/ti/knav_qmss_queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index d66aaf2..6f22d56 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -1640,7 +1640,7 @@ static int knav_queue_init_queues(struct knav_device *kdev)
size = (1 << kdev->inst_shift) * kdev->num_queues_in_use;
kdev->instances = devm_kzalloc(kdev->dev, size, GFP_KERNEL);
if (!kdev->instances)
- return -1;
+ return -ENOMEM;
for_each_queue_range(kdev, range) {
if (range->ops && range->ops->init_range)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] soc: ti: knav_qmss_queue: Return proper error if devm_kzalloc fails
@ 2014-10-26 9:39 ` Axel Lin
0 siblings, 0 replies; 8+ messages in thread
From: Axel Lin @ 2014-10-26 9:39 UTC (permalink / raw)
To: linux-arm-kernel
Return -ENOMEM if devm_kzalloc fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/soc/ti/knav_qmss_queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index d66aaf2..6f22d56 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -1640,7 +1640,7 @@ static int knav_queue_init_queues(struct knav_device *kdev)
size = (1 << kdev->inst_shift) * kdev->num_queues_in_use;
kdev->instances = devm_kzalloc(kdev->dev, size, GFP_KERNEL);
if (!kdev->instances)
- return -1;
+ return -ENOMEM;
for_each_queue_range(kdev, range) {
if (range->ops && range->ops->init_range)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] soc: ti: Use list_first_entry_or_null() at appropriate places
2014-10-26 9:37 ` Axel Lin
@ 2014-10-27 16:34 ` Santosh Shilimkar
-1 siblings, 0 replies; 8+ messages in thread
From: Santosh Shilimkar @ 2014-10-27 16:34 UTC (permalink / raw)
To: Axel Lin, Santosh Shilimkar; +Cc: Sandeep Nair, linux-kernel, linux-arm-kernel
Alex,
On 10/26/2014 02:37 AM, Axel Lin wrote:
> Use list_first_entry_or_null() for first_region() and first_queue_range().
>
> list_first_entry() expects the list is not empty, so first_region() and
> first_queue_range() never return NULL.
> Thus use list_first_entry_or_null() instead.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
Thanks. I will pick the $subject and other two patches and queue
them up for next merge window.
Regards,
Santosh
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] soc: ti: Use list_first_entry_or_null() at appropriate places
@ 2014-10-27 16:34 ` Santosh Shilimkar
0 siblings, 0 replies; 8+ messages in thread
From: Santosh Shilimkar @ 2014-10-27 16:34 UTC (permalink / raw)
To: linux-arm-kernel
Alex,
On 10/26/2014 02:37 AM, Axel Lin wrote:
> Use list_first_entry_or_null() for first_region() and first_queue_range().
>
> list_first_entry() expects the list is not empty, so first_region() and
> first_queue_range() never return NULL.
> Thus use list_first_entry_or_null() instead.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
Thanks. I will pick the $subject and other two patches and queue
them up for next merge window.
Regards,
Santosh
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-10-27 16:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-26 9:37 [PATCH 1/3] soc: ti: Use list_first_entry_or_null() at appropriate places Axel Lin
2014-10-26 9:37 ` Axel Lin
2014-10-26 9:38 ` [PATCH 2/3] soc: ti: knav_qmss_queue: Fix unbalanced locking in knav_pool_create() Axel Lin
2014-10-26 9:38 ` Axel Lin
2014-10-26 9:39 ` [PATCH 3/3] soc: ti: knav_qmss_queue: Return proper error if devm_kzalloc fails Axel Lin
2014-10-26 9:39 ` Axel Lin
2014-10-27 16:34 ` [PATCH 1/3] soc: ti: Use list_first_entry_or_null() at appropriate places Santosh Shilimkar
2014-10-27 16:34 ` Santosh Shilimkar
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.