[RAMEN9610-15104] usb: gadget: add null check on mtp read/write
authorSEO HOYOUNG <hy50.seo@samsung.com>
Fri, 17 May 2019 01:40:45 +0000 (10:40 +0900)
committerKim Gunho <gunho.kim@samsung.com>
Fri, 28 Jun 2019 14:45:00 +0000 (23:45 +0900)
Change-Id: I945f116762cfcb836b7e5273b1dd2ce15413a3fd
Signed-off-by: SEO HOYOUNG <hy50.seo@samsung.com>
drivers/usb/gadget/function/f_mtp.c

index 9b8b6f4a2c70b29c6465fd34cc33eacd658afe95..302f073370e1c0bc29f4b47974ab03635b737013 100644 (file)
@@ -564,6 +564,11 @@ static ssize_t mtp_read(struct file *fp, char __user *buf,
        int ret = 0;\r
        size_t len = 0;\r
 \r
+       if (!cdev) {\r
+               pr_err("%s: check cdev is NULL\n", __func__);\r
+               return -EINVAL;\r
+       }\r
+\r
        DBG(cdev, "mtp_read(%zu)\n", count);\r
 \r
        /* we will block until we're online */\r
@@ -649,6 +654,11 @@ static ssize_t mtp_write(struct file *fp, const char __user *buf,
        int sendZLP = 0;\r
        int ret;\r
 \r
+       if (!cdev) {\r
+               pr_err("%s: check cdev is NULL\n", __func__);\r
+               return -EINVAL;\r
+       }\r
+\r
        DBG(cdev, "mtp_write(%zu)\n", count);\r
 \r
        spin_lock_irq(&dev->lock);\r