Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754009AbaD0RIC (ORCPT ); Sun, 27 Apr 2014 13:08:02 -0400 Received: from linuxhacker.ru ([217.76.32.60]:48015 "EHLO fiona.linuxhacker.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753929AbaD0RH6 (ORCPT ); Sun, 27 Apr 2014 13:07:58 -0400 From: Oleg Drokin To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org Cc: Peng Tao , Oleg Drokin Subject: [PATCH 17/47] staging/lustre/hsm: count NULL terminator in hai_zero/hal_size Date: Sun, 27 Apr 2014 13:06:41 -0400 Message-Id: <1398618431-29757-18-git-send-email-green@linuxhacker.ru> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1398618431-29757-1-git-send-email-green@linuxhacker.ru> References: <1398618431-29757-1-git-send-email-green@linuxhacker.ru> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Tao 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 Reviewed-on: http://review.whamcloud.com/9431 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4689 Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/include/lustre/lustre_user.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index f5f369e..95c754f 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -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); -- 1.8.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/