提交 c7a6252b 编写于 作者: A Alexander Usyskin 提交者: Greg Kroah-Hartman

mei: bus: do not start a read for disconnected clients

Avoid queuing reads and registering rx callbacks in
case the client is not connected, to prevent null
dereferencing and memory leaks.
Signed-off-by: NAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: NTomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20201029095444.957924-3-tomas.winkler@intel.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a7c392c7
......@@ -276,7 +276,8 @@ static void mei_cl_bus_rx_work(struct work_struct *work)
cldev->rx_cb(cldev);
mutex_lock(&bus->device_lock);
mei_cl_read_start(cldev->cl, mei_cl_mtu(cldev->cl), NULL);
if (mei_cl_is_connected(cldev->cl))
mei_cl_read_start(cldev->cl, mei_cl_mtu(cldev->cl), NULL);
mutex_unlock(&bus->device_lock);
}
......@@ -364,7 +365,10 @@ int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb)
INIT_WORK(&cldev->rx_work, mei_cl_bus_rx_work);
mutex_lock(&bus->device_lock);
ret = mei_cl_read_start(cldev->cl, mei_cl_mtu(cldev->cl), NULL);
if (mei_cl_is_connected(cldev->cl))
ret = mei_cl_read_start(cldev->cl, mei_cl_mtu(cldev->cl), NULL);
else
ret = -ENODEV;
mutex_unlock(&bus->device_lock);
if (ret && ret != -EBUSY)
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册