[FIX] Driver: add maximum subbuffer size 60/15260/15
authorAlexander Aksenov <a.aksenov@samsung.com>
Fri, 17 Jan 2014 11:34:27 +0000 (15:34 +0400)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Thu, 27 Mar 2014 08:45:44 +0000 (01:45 -0700)
Change-Id: Ia39eb9d1d3d5f2b2284f92a5691b87a70ab236df
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
driver/device_driver.c

index af7f9e5..9a567d9 100644 (file)
@@ -50,6 +50,8 @@
 
 #define SWAP_DEVICE_NAME "swap_device"
 
+#define MAXIMUM_SUBBUFFER_SIZE (64 * 1024)
+
 /* swap_device driver routines */
 static int swap_device_open(struct inode *inode, struct file *filp);
 static int swap_device_release(struct inode *inode, struct file *file);
@@ -308,6 +310,12 @@ static long swap_device_ioctl(struct file *filp, unsigned int cmd,
                                break;
                        }
 
+                       if (initialize_struct.size > MAXIMUM_SUBBUFFER_SIZE) {
+                               print_err("Wrong subbuffer size\n");
+                               result = -E_SD_WRONG_ARGS;
+                               break;
+                       }
+
                        result = driver_to_buffer_initialize(initialize_struct.size,
                                                                                                 initialize_struct.count);
                        if (result < 0) {