[NEUS7920-133]wlbt: Return -EACCES from scsc_bt_shm_h4_read when copy_from_user fails
authorJes Andersen <jes.andersen@samsung.com>
Thu, 21 Mar 2019 11:22:37 +0000 (12:22 +0100)
committerYoungmin Nam <youngmin.nam@samsung.com>
Tue, 21 May 2019 10:45:22 +0000 (19:45 +0900)
Otherwise it could end up in an infinite loop.

Change-Id: I98d2729e669c8846e3c1e939fc3453f957ae2a3e
SCSC-Bug-Id: SSB-45750
Signed-off-by: Jes Andersen <jes.andersen@samsung.com>
drivers/misc/samsung/scsc_bt/scsc_shm.c

index 070d97106ca696d37ec535a2eacbfe57aacfb428..12e0903dfd33a27c38b0b7dd61c3d5e0e2f648f1 100755 (executable)
@@ -1295,30 +1295,34 @@ ssize_t scsc_bt_shm_h4_read(struct file *file, char __user *buf, size_t len, lof
 
                /* First: process any pending HCI event that needs to be sent to userspace */
                res = scsc_bt_shm_h4_read_hci_evt(&buf[consumed], len - consumed);
-               if (0 < res)
-                       consumed += res;
-               else
+               if (res < 0) {
                        ret = res;
+                       break;
+               }
+               consumed += res;
 
                /* Second: process any pending ACL data that needs to be sent to userspace */
                res = scsc_bt_shm_h4_read_acl_data(&buf[consumed], len - consumed);
-               if (0 < res)
-                       consumed += res;
-               else
+               if (res < 0) {
                        ret = res;
+                       break;
+               }
+               consumed += res;
 
                /* Third: process any pending ACL data that needs to be sent to userspace */
                res = scsc_bt_shm_h4_read_acl_credit(&buf[consumed], len - consumed);
-               if (0 < res)
-                       consumed += res;
-               else
+               if (res < 0) {
                        ret = res;
+                       break;
+               }
+               consumed += res;
 
                res = scsc_bt_shm_h4_read_iq_report_evt(&buf[consumed], len - consumed);
-               if (res > 0)
-                       consumed += res;
-               else
+               if (res < 0) {
                        ret = res;
+                       break;
+               }
+               consumed += res;
        }
 
        if (0 == ret && 0 == consumed) {