提交 84d4333c 编写于 作者: W Won Chung 提交者: Mika Westerberg

misc/mei: Add NULL check to component match callback functions

Currently, component_match callback functions used in mei refers to the
driver name, assuming that the component device being matched has a
driver bound. It can cause a NULL pointer dereference when a device
without a driver bound registers a component. This is due to the nature
of the component framework where all registered components are matched
in any component_match callback functions. So even if a component is
registered by a totally irrelevant device, that component is also
shared to these callbacks for i915 driver.

To prevent totally irrelevant device being matched for i915 and causing
a NULL pointer dereference for checking driver name, add a NULL check on
dev->driver to check if there is a driver bound before checking the
driver name.

In the future, the string compare on the driver name, "i915" may need to
be refactored too.
Reviewed-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: NPrashant Malani <pmalani@chromium.org>
Signed-off-by: NWon Chung <wonchung@google.com>
Acked-by: NTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
上级 9d2d0a5c
......@@ -784,7 +784,7 @@ static int mei_hdcp_component_match(struct device *dev, int subcomponent,
{
struct device *base = data;
if (strcmp(dev->driver->name, "i915") ||
if (!dev->driver || strcmp(dev->driver->name, "i915") ||
subcomponent != I915_COMPONENT_HDCP)
return 0;
......
......@@ -131,7 +131,7 @@ static int mei_pxp_component_match(struct device *dev, int subcomponent,
{
struct device *base = data;
if (strcmp(dev->driver->name, "i915") ||
if (!dev->driver || strcmp(dev->driver->name, "i915") ||
subcomponent != I915_COMPONENT_PXP)
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册