drm: Prevent drm_copy_field() to attempt copying a NULL pointer
[linux-2.6-microblaze.git] / drivers / gpu / drm / drm_ioctl.c
index e1b9a03..ca2a6e6 100644 (file)
@@ -474,6 +474,12 @@ static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
 {
        size_t len;
 
+       /* don't attempt to copy a NULL pointer */
+       if (WARN_ONCE(!value, "BUG: the value to copy was not set!")) {
+               *buf_len = 0;
+               return 0;
+       }
+
        /* don't overflow userbuf */
        len = strlen(value);
        if (len > *buf_len)