From: Won Chung <wonchung@google.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Alexander Usyskin <alexander.usyskin@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Benson Leung <bleung@chromium.org>,
Prashant Malani <pmalani@chromium.org>,
Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>,
linux-kernel@vger.kernel.org
Cc: Won Chung <wonchung@google.com>
Subject: [PATCH 1/2] misc/mei: Add NULL check to component match callback functions
Date: Mon, 18 Apr 2022 17:59:31 +0000 [thread overview]
Message-ID: <20220418175932.1809770-2-wonchung@google.com> (raw)
In-Reply-To: <20220418175932.1809770-1-wonchung@google.com>
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: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Won Chung <wonchung@google.com>
---
drivers/misc/mei/hdcp/mei_hdcp.c | 2 +-
drivers/misc/mei/pxp/mei_pxp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c
index ec2a4fce8581..e889a8bd7ac8 100644
--- a/drivers/misc/mei/hdcp/mei_hdcp.c
+++ b/drivers/misc/mei/hdcp/mei_hdcp.c
@@ -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;
diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c
index f7380d387bab..5c39457e3f53 100644
--- a/drivers/misc/mei/pxp/mei_pxp.c
+++ b/drivers/misc/mei/pxp/mei_pxp.c
@@ -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;
--
2.36.0.rc0.470.gd361397f0d-goog
next prev parent reply other threads:[~2022-04-18 17:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-18 17:59 [PATCH 0/2] thunderbolt: Link USB4 ports to their USB Type-C connectors Won Chung
2022-04-18 17:59 ` Won Chung [this message]
2022-04-25 16:56 ` [PATCH 1/2] misc/mei: Add NULL check to component match callback functions Won Chung
2022-04-28 18:11 ` Winkler, Tomas
2022-04-18 17:59 ` [PATCH 2/2] thunderbolt: Link USB4 ports to their USB Type-C connectors Won Chung
2022-04-20 10:52 ` [PATCH 0/2] " Mika Westerberg
2022-04-20 16:39 ` Won Chung
2022-04-21 6:00 ` Mika Westerberg
2022-04-24 5:12 ` Usyskin, Alexander
2022-04-25 16:51 ` Won Chung
2022-04-28 18:34 ` Won Chung
2022-04-29 9:28 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220418175932.1809770-2-wonchung@google.com \
--to=wonchung@google.com \
--cc=alexander.usyskin@intel.com \
--cc=bleung@chromium.org \
--cc=daniele.ceraolospurio@intel.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=pmalani@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).