|
|
4e6258a |
From 9f1f1a2dab38d4ce87a13565cf4dc1b73bef3a5f Mon Sep 17 00:00:00 2001
|
|
|
4e6258a |
From: Gen Zhang <blackgod016574@gmail.com>
|
|
|
4e6258a |
Date: Fri, 24 May 2019 10:32:22 +0800
|
|
|
4e6258a |
Subject: drm/edid: Fix a missing-check bug in drm_load_edid_firmware()
|
|
|
4e6258a |
|
|
|
4e6258a |
In drm_load_edid_firmware(), fwstr is allocated by kstrdup(). And fwstr
|
|
|
4e6258a |
is dereferenced in the following codes. However, memory allocation
|
|
|
4e6258a |
functions such as kstrdup() may fail and returns NULL. Dereferencing
|
|
|
4e6258a |
this null pointer may cause the kernel go wrong. Thus we should check
|
|
|
4e6258a |
this kstrdup() operation.
|
|
|
4e6258a |
Further, if kstrdup() returns NULL, we should return ERR_PTR(-ENOMEM) to
|
|
|
4e6258a |
the caller site.
|
|
|
4e6258a |
|
|
|
4e6258a |
Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
|
|
|
4e6258a |
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
|
|
|
4e6258a |
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
|
|
|
4e6258a |
Link: https://patchwork.freedesktop.org/patch/msgid/20190524023222.GA5302@zhanggen-UX430UQ
|
|
|
4e6258a |
---
|
|
|
4e6258a |
drivers/gpu/drm/drm_edid_load.c | 2 ++
|
|
|
4e6258a |
1 file changed, 2 insertions(+)
|
|
|
4e6258a |
|
|
|
4e6258a |
diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
|
|
|
4e6258a |
index 18d52dc..2e8d043 100644
|
|
|
4e6258a |
--- a/drivers/gpu/drm/drm_edid_load.c
|
|
|
4e6258a |
+++ b/drivers/gpu/drm/drm_edid_load.c
|
|
|
4e6258a |
@@ -293,6 +293,8 @@ struct edid *drm_load_edid_firmware(struct drm_connector *connector)
|
|
|
4e6258a |
* the last one found one as a fallback.
|
|
|
4e6258a |
*/
|
|
|
4e6258a |
fwstr = kstrdup(edid_firmware, GFP_KERNEL);
|
|
|
4e6258a |
+ if (!fwstr)
|
|
|
4e6258a |
+ return ERR_PTR(-ENOMEM);
|
|
|
4e6258a |
edidstr = fwstr;
|
|
|
4e6258a |
|
|
|
4e6258a |
while ((edidname = strsep(&edidstr, ","))) {
|
|
|
4e6258a |
--
|
|
|
4e6258a |
cgit v1.1
|
|
|
4e6258a |
|