]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
staging/lustre/hsm: count NULL terminator in hai_zero/hal_size
authorPeng Tao <bergwolf@gmail.com>
Sun, 27 Apr 2014 17:06:41 +0000 (13:06 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 27 Apr 2014 17:23:16 +0000 (10:23 -0700)
If fsname is 8-byte aligned, hai_zero fails to count the ending NULL
terminator causing hai to directly attached after fsname and future
hai_zero will return a different position for first hai.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Reviewed-on: http://review.whamcloud.com/9431
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4689
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lustre/lustre_user.h

index f5f369e603def0286d32edd8bd7be8b5a36dbaa4..95c754f2075f4f211d23a70ead54c8068aa70717 100644 (file)
@@ -1106,7 +1106,8 @@ static inline struct hsm_action_item * hai_zero(struct hsm_action_list *hal)
 {
        return (struct hsm_action_item *)(hal->hal_fsname +
                                          cfs_size_round(strlen(hal-> \
-                                                               hal_fsname)));
+                                                               hal_fsname)
+                                                        + 1));
 }
 /* Return pointer to next hai */
 static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai)
@@ -1121,7 +1122,7 @@ static inline int hal_size(struct hsm_action_list *hal)
        int i, sz;
        struct hsm_action_item *hai;
 
-       sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname));
+       sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname) + 1);
        hai = hai_zero(hal);
        for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai))
                sz += cfs_size_round(hai->hai_len);