component: fix bug with legacy API
authorRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 4 Jul 2014 12:23:46 +0000 (13:23 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 4 Jul 2014 17:05:05 +0000 (18:05 +0100)
Sachin Kamat reports that "component: add support for component match
array" broke Exynos DRM due to a NULL pointer deref.  Fix this.

Reported-by: Sachin Kamat <sachin.kamat@samsung.com>
Tested-by: Sachin Kamat <sachin.kamat@samsung.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/base/component.c

index b4236da..f748430 100644 (file)
@@ -293,10 +293,12 @@ int component_master_add_with_match(struct device *dev,
        if (ops->add_components && match)
                return -EINVAL;
 
-       /* Reallocate the match array for its true size */
-       match = component_match_realloc(dev, match, match->num);
-       if (IS_ERR(match))
-               return PTR_ERR(match);
+       if (match) {
+               /* Reallocate the match array for its true size */
+               match = component_match_realloc(dev, match, match->num);
+               if (IS_ERR(match))
+                       return PTR_ERR(match);
+       }
 
        master = kzalloc(sizeof(*master), GFP_KERNEL);
        if (!master)