drm/edid: make drm_edid_duplicate() safe to call with NULL parameter
authorJani Nikula <jani.nikula@intel.com>
Tue, 30 May 2023 09:08:23 +0000 (12:08 +0300)
committerJani Nikula <jani.nikula@intel.com>
Fri, 2 Jun 2023 10:23:30 +0000 (13:23 +0300)
It's a bit tedious to check for NULL before calling
drm_edid_duplicate(). Make it handle NULL parameter graciously.

Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1ae8923d39a5abd0260fdf7f9cc54c5e046e70d3.1685437501.git.jani.nikula@intel.com
drivers/gpu/drm/drm_edid.c

index 941f3d5..e0dbd91 100644 (file)
@@ -2881,6 +2881,9 @@ EXPORT_SYMBOL(drm_edid_read_switcheroo);
  */
 struct edid *drm_edid_duplicate(const struct edid *edid)
 {
+       if (!edid)
+               return NULL;
+
        return kmemdup(edid, edid_size(edid), GFP_KERNEL);
 }
 EXPORT_SYMBOL(drm_edid_duplicate);