[FIX] fixing problem from Barinov when __switch_to was't collected
authorKudrjavtsev Nickita <n.kudryavcev@samsung.com>
Mon, 18 Mar 2013 15:29:02 +0000 (19:29 +0400)
committerKudrjavtsev Nickita <n.kudryavcev@samsung.com>
Mon, 18 Mar 2013 15:29:02 +0000 (19:29 +0400)
driver/device_driver.c
driver/error_storage.c
driver/error_storage.h
driver/storage.h

index 1699aee..1fe26d1 100644 (file)
@@ -409,12 +409,15 @@ static long device_ioctl (struct file *file UNUSED, unsigned int cmd, unsigned l
                }
                DPRINTF("Bundle has been copied successfully");
 
+               last_error_buffer_initialize();
+
                if (link_bundle() == -1) {
                        EPRINTF("Cannot link profile bundle!");
                        result = -1;
                        break;
                }
                if (has_last_error() == -1) {
+                       EPRINTF("last_error_buffer != NULL");
                        result = -1;
                }
 
index 53f31f9..7e3dcaf 100644 (file)
@@ -15,6 +15,11 @@ struct errno_struct
 
 static struct errno_struct *last_error = NULL;
 
+void last_error_buffer_initialize(void)
+{
+       last_error = NULL;
+}
+
 static int create_errno_buffer(void)
 {
         struct errno_struct *error = NULL;
@@ -47,15 +52,14 @@ int update_errno_buffer(const char *buffer)
 {
         unsigned int size;
 
-        if (last_error == NULL)
-        {
+        if (last_error == NULL) {
                 if (create_errno_buffer() != 0)
                         return -1;
         }
 
         size = strlen(buffer);
 
-        if (last_error->size + size + 1 >= get_max_error_buffer_size()) {
+        if (last_error->size + size + 2 >= get_max_error_buffer_size()) {
                 return -1;
        }
 
@@ -70,8 +74,9 @@ int update_errno_buffer(const char *buffer)
 
 static void delete_errno_buffer(void)
 {
-        if (last_error == NULL)
+        if (last_error == NULL) {
                 return;
+       }
 
         vfree((char*)last_error->buffer);
         vfree(last_error);
@@ -85,8 +90,9 @@ int get_last_error(void* u_addr)
 {
         int result;
 
-        if (last_error == NULL)
+        if (last_error == NULL) {
                 return -1;
+       }
 
         result = copy_to_user ((void*)u_addr, (void*)(last_error->buffer), last_error->size + 1);
         if (result) {
@@ -100,7 +106,8 @@ int get_last_error(void* u_addr)
 
 int has_last_error()
 {
-        if(last_error == NULL)
+        if(last_error == NULL) {
                 return 0;
+       }
         return -1;
 }
index d32b4f1..4ba8c29 100644 (file)
@@ -4,3 +4,4 @@
 int get_last_error(void* u_addr);
 int has_last_error(void);
 int update_errno_buffer(const char *buffer);
+void last_error_buffer_initialize(void);
index a778091..91314d5 100644 (file)
@@ -32,6 +32,7 @@
 extern int update_errno_buffer(const char *buffer);
 extern int get_last_error(void* u_addr);
 extern int has_last_error(void);
+extern void last_error_buffer_initialize(void);
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 extern int EnableContinuousRetrieval(void);