* [PATCH] tcmu: Oops in unmap_thread_fn()
@ 2017-08-01 20:09 Dan Carpenter
2017-08-02 3:25 ` Xiubo Li
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2017-08-01 20:09 UTC (permalink / raw)
To: Nicholas A. Bellinger, Xiubo Li; +Cc: linux-scsi, target-devel, kernel-janitors
Calling list_del() on the iterator pointer in list_for_each_entry() will
cause an oops. We need to user the _safe() version for that.
Fixes: c73d02f63c16 ("tcmu: Add fifo type waiter list support to avoid starvation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 9258b7dd2c30..fd9fcea68d23 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1985,7 +1985,7 @@ static struct target_backend_ops tcmu_ops = {
static int unmap_thread_fn(void *data)
{
- struct tcmu_dev *udev;
+ struct tcmu_dev *udev, *tmp;
loff_t off;
uint32_t start, end, block;
static uint32_t free_blocks;
@@ -2056,7 +2056,7 @@ static int unmap_thread_fn(void *data)
* for the global data pool blocks.
*/
mutex_lock(&root_udev_waiter_mutex);
- list_for_each_entry(udev, &root_udev_waiter, waiter) {
+ list_for_each_entry_safe(udev, tmp, &root_udev_waiter, waiter) {
mutex_lock(&udev->cmdr_lock);
if (udev->waiting_blocks < free_blocks) {
mutex_unlock(&udev->cmdr_lock);
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] tcmu: Oops in unmap_thread_fn()
2017-08-01 20:09 [PATCH] tcmu: Oops in unmap_thread_fn() Dan Carpenter
@ 2017-08-02 3:25 ` Xiubo Li
2017-08-03 17:35 ` Mike Christie
2017-08-06 23:27 ` Nicholas A. Bellinger
2 siblings, 0 replies; 5+ messages in thread
From: Xiubo Li @ 2017-08-02 3:25 UTC (permalink / raw)
To: Dan Carpenter, Nicholas A. Bellinger
Cc: linux-scsi, target-devel, kernel-janitors
On 2017年08月02日 04:09, Dan Carpenter wrote:
> Calling list_del() on the iterator pointer in list_for_each_entry() will
> cause an oops. We need to user the _safe() version for that.
>
> Fixes: c73d02f63c16 ("tcmu: Add fifo type waiter list support to avoid starvation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 9258b7dd2c30..fd9fcea68d23 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1985,7 +1985,7 @@ static struct target_backend_ops tcmu_ops = {
>
> static int unmap_thread_fn(void *data)
> {
> - struct tcmu_dev *udev;
> + struct tcmu_dev *udev, *tmp;
> loff_t off;
> uint32_t start, end, block;
> static uint32_t free_blocks;
> @@ -2056,7 +2056,7 @@ static int unmap_thread_fn(void *data)
> * for the global data pool blocks.
> */
> mutex_lock(&root_udev_waiter_mutex);
> - list_for_each_entry(udev, &root_udev_waiter, waiter) {
> + list_for_each_entry_safe(udev, tmp, &root_udev_waiter, waiter) {
> mutex_lock(&udev->cmdr_lock);
> if (udev->waiting_blocks < free_blocks) {
> mutex_unlock(&udev->cmdr_lock);
Good catch and it looks nice for me.
Thanks,
BRs
Xiubo
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] tcmu: Oops in unmap_thread_fn()
2017-08-01 20:09 [PATCH] tcmu: Oops in unmap_thread_fn() Dan Carpenter
2017-08-02 3:25 ` Xiubo Li
@ 2017-08-03 17:35 ` Mike Christie
2017-08-06 23:27 ` Nicholas A. Bellinger
2 siblings, 0 replies; 5+ messages in thread
From: Mike Christie @ 2017-08-03 17:35 UTC (permalink / raw)
To: Dan Carpenter, Nicholas A. Bellinger, Xiubo Li
Cc: linux-scsi, target-devel, kernel-janitors
On 08/01/2017 03:09 PM, Dan Carpenter wrote:
> Calling list_del() on the iterator pointer in list_for_each_entry() will
> cause an oops. We need to user the _safe() version for that.
>
> Fixes: c73d02f63c16 ("tcmu: Add fifo type waiter list support to avoid starvation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 9258b7dd2c30..fd9fcea68d23 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1985,7 +1985,7 @@ static struct target_backend_ops tcmu_ops = {
>
> static int unmap_thread_fn(void *data)
> {
> - struct tcmu_dev *udev;
> + struct tcmu_dev *udev, *tmp;
> loff_t off;
> uint32_t start, end, block;
> static uint32_t free_blocks;
> @@ -2056,7 +2056,7 @@ static int unmap_thread_fn(void *data)
> * for the global data pool blocks.
> */
> mutex_lock(&root_udev_waiter_mutex);
> - list_for_each_entry(udev, &root_udev_waiter, waiter) {
> + list_for_each_entry_safe(udev, tmp, &root_udev_waiter, waiter) {
> mutex_lock(&udev->cmdr_lock);
> if (udev->waiting_blocks < free_blocks) {
> mutex_unlock(&udev->cmdr_lock);
>
Thanks.
Reviewed-by: Mike Christie <mchristi@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] tcmu: Oops in unmap_thread_fn()
2017-08-01 20:09 [PATCH] tcmu: Oops in unmap_thread_fn() Dan Carpenter
2017-08-02 3:25 ` Xiubo Li
2017-08-03 17:35 ` Mike Christie
@ 2017-08-06 23:27 ` Nicholas A. Bellinger
2017-11-08 22:41 ` Bryant G. Ly
2 siblings, 1 reply; 5+ messages in thread
From: Nicholas A. Bellinger @ 2017-08-06 23:27 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Xiubo Li, linux-scsi, target-devel, kernel-janitors
On Tue, 2017-08-01 at 23:09 +0300, Dan Carpenter wrote:
> Calling list_del() on the iterator pointer in list_for_each_entry() will
> cause an oops. We need to user the _safe() version for that.
>
> Fixes: c73d02f63c16 ("tcmu: Add fifo type waiter list support to avoid starvation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
Applied to target-pending/for-next.
Thanks DanC.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] tcmu: Oops in unmap_thread_fn()
2017-08-06 23:27 ` Nicholas A. Bellinger
@ 2017-11-08 22:41 ` Bryant G. Ly
0 siblings, 0 replies; 5+ messages in thread
From: Bryant G. Ly @ 2017-11-08 22:41 UTC (permalink / raw)
To: Nicholas A. Bellinger, Dan Carpenter
Cc: Xiubo Li, linux-scsi, target-devel, kernel-janitors
On 8/6/17 6:27 PM, Nicholas A. Bellinger wrote:
> On Tue, 2017-08-01 at 23:09 +0300, Dan Carpenter wrote:
>> Calling list_del() on the iterator pointer in list_for_each_entry() will
>> cause an oops. We need to user the _safe() version for that.
>>
>> Fixes: c73d02f63c16 ("tcmu: Add fifo type waiter list support to avoid starvation")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
> Applied to target-pending/for-next.
>
> Thanks DanC.
>
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Also missing.
-Bryant
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-11-08 22:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 20:09 [PATCH] tcmu: Oops in unmap_thread_fn() Dan Carpenter
2017-08-02 3:25 ` Xiubo Li
2017-08-03 17:35 ` Mike Christie
2017-08-06 23:27 ` Nicholas A. Bellinger
2017-11-08 22:41 ` Bryant G. Ly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).