mei: fix NULL dereferencing during FW initiated disconnection
authorAlexander Usyskin <alexander.usyskin@intel.com>
Sun, 17 Apr 2016 16:16:03 +0000 (12:16 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Jun 2016 19:15:50 +0000 (12:15 -0700)
commit 6a8d648c8d1824117a9e9edb948ed1611fb013c0 upstream.

In the case when disconnection is initiated from the FW
the driver is flushing items from the write control list while
iterating over it:

mei_irq_write_handler()
    list_for_each_entry_safe(ctrl_wr_list)         <-- outer loop
         mei_cl_irq_disconnect_rsp()
             mei_cl_set_disconnected()
                 mei_io_list_flush(ctrl_wr_list)   <-- destorying list

We move the list flushing to the completion routine.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/client.c
drivers/misc/mei/hbm.c
drivers/misc/mei/interrupt.c

index a6c87c713193808365071a8e0ad34fd17cea0eab..958af84884b57e8af7b68df6d3ab7319a963b583 100644 (file)
@@ -1734,6 +1734,10 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
                if (waitqueue_active(&cl->wait))
                        wake_up(&cl->wait);
 
+               break;
+       case MEI_FOP_DISCONNECT_RSP:
+               mei_io_cb_free(cb);
+               mei_cl_set_disconnected(cl);
                break;
        default:
                BUG_ON(0);
index e7b7aad0999bc665e01da3c94b75ee91caa86c31..fd8a9f057ea644227e779e00febdfa3836e811fd 100644 (file)
@@ -873,8 +873,7 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
                cb = mei_io_cb_init(cl, MEI_FOP_DISCONNECT_RSP, NULL);
                if (!cb)
                        return -ENOMEM;
-               cl_dbg(dev, cl, "add disconnect response as first\n");
-               list_add(&cb->list, &dev->ctrl_wr_list.list);
+               list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
        }
        return 0;
 }
index 64b568a0268d7026d7305f3233c378900e5669f4..44471edb62f7fcf48f75e704fed634187e441dfb 100644 (file)
@@ -184,10 +184,7 @@ static int mei_cl_irq_disconnect_rsp(struct mei_cl *cl, struct mei_cl_cb *cb,
                return -EMSGSIZE;
 
        ret = mei_hbm_cl_disconnect_rsp(dev, cl);
-       mei_cl_set_disconnected(cl);
-       mei_io_cb_free(cb);
-       mei_me_cl_put(cl->me_cl);
-       cl->me_cl = NULL;
+       list_move_tail(&cb->list, &cmpl_list->list);
 
        return ret;
 }