Whamcloud - gitweb
LU-6505 libcfs: Use after free in __proc_cpt_table 02/14602/2
authorOleg Drokin <oleg.drokin@intel.com>
Mon, 27 Apr 2015 02:43:54 +0000 (22:43 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 20 May 2015 17:30:26 +0000 (17:30 +0000)
Only free the too small buffer if it's really too small, not always.

Change-Id: I3fbdcb74dd0091c43aeb3e5b98460c203595bc19
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/14602
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: frank zago <fzago@cray.com>
libcfs/libcfs/linux/linux-proc.c

index bbab089..37a98b7 100644 (file)
@@ -348,8 +348,8 @@ static int __proc_cpt_table(void *data, int write,
                if (rc >= 0)
                        break;
 
                if (rc >= 0)
                        break;
 
-               LIBCFS_FREE(buf, len);
                if (rc == -EFBIG) {
                if (rc == -EFBIG) {
+                       LIBCFS_FREE(buf, len);
                        len <<= 1;
                        continue;
                }
                        len <<= 1;
                        continue;
                }