From: Bobi Jam Date: Wed, 24 Aug 2011 04:07:22 +0000 (+0800) Subject: LU-622 Alloc enough cfg buffer space X-Git-Tag: 2.1.0~9 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=ed2e4d8205e5b6bc9dc2ad8319ad7666e49e5dfe LU-622 Alloc enough cfg buffer space obd device name needs space enough for "-\0". This fixes the glitch in commit cbc4ca2e8dc37d54bb7d3c9b02ab20b63e60f592. Change-Id: Ib8c3c8db49baad8a9ca068a1c8009aee72aa1e62 Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/1280 Tested-by: Hudson Reviewed-by: Oleg Drokin Reviewed-by: Jinshan Xiong Reviewed-by: Yu Jian Tested-by: Yu Jian --- diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 9c479f5..447481e 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -1858,6 +1858,8 @@ llu_fsswop_mount(const char *source, int async = 1, err = -EINVAL; struct obd_connect_data ocd = {0,}; struct md_op_data op_data = {{0}}; + /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ + const int instlen = sizeof(cfg.cfg_instance) * 2 + 2; ENTRY; @@ -1897,10 +1899,10 @@ llu_fsswop_mount(const char *source, CERROR("No profile found: %s\n", zconf_profile); GOTO(out_free, err = -EINVAL); } - OBD_ALLOC(osc, strlen(lprof->lp_dt) + sizeof(cfg.cfg_instance)*2 + 1); + OBD_ALLOC(osc, strlen(lprof->lp_dt) + instlen + 2); sprintf(osc, "%s-%p", lprof->lp_dt, cfg.cfg_instance); - OBD_ALLOC(mdc, strlen(lprof->lp_md) + sizeof(cfg.cfg_instance)*2 + 1); + OBD_ALLOC(mdc, strlen(lprof->lp_md) + instlen + 2); sprintf(mdc, "%s-%p", lprof->lp_md, cfg.cfg_instance); if (!osc) { @@ -2034,9 +2036,8 @@ llu_fsswop_mount(const char *source, ptlrpc_req_finished(request); CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source); - liblustre_wait_idle(); - - return 0; + err = 0; + goto out_free; out_inode: _sysio_i_gone(root); @@ -2048,9 +2049,9 @@ out_md: obd_disconnect(sbi->ll_md_exp); out_free: if (osc) - OBD_FREE(osc, strlen(osc) + 1); + OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2); if (mdc) - OBD_FREE(mdc, strlen(mdc) + 1); + OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2); OBD_FREE(sbi, sizeof(*sbi)); liblustre_wait_idle(); return err; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index a0b5027..f97250b 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -900,7 +900,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) char *dt = NULL, *md = NULL; char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; - const int instlen = sizeof(cfg->cfg_instance) * 2 + 1; + /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ + const int instlen = sizeof(cfg->cfg_instance) * 2 + 2; int err; ENTRY; @@ -961,12 +962,12 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm, lprof->lp_md, lprof->lp_dt); - OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen); + OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen + 2); if (!dt) GOTO(out_free, err = -ENOMEM); sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance); - OBD_ALLOC(md, strlen(lprof->lp_md) + instlen); + OBD_ALLOC(md, strlen(lprof->lp_md) + instlen + 2); if (!md) GOTO(out_free, err = -ENOMEM); sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance); @@ -976,9 +977,9 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) out_free: if (md) - OBD_FREE(md, strlen(lprof->lp_md) + instlen); + OBD_FREE(md, strlen(lprof->lp_md) + instlen + 2); if (dt) - OBD_FREE(dt, strlen(lprof->lp_dt) + instlen); + OBD_FREE(dt, strlen(lprof->lp_dt) + instlen + 2); if (err) ll_put_super(sb); else diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 49469af..f9fa331 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -1286,7 +1286,7 @@ static int class_config_llog_handler(struct llog_handle * handle, LUSTRE_CFG_BUFLEN(lcfg, 0) > 0){ inst = 1; inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + - sizeof(clli->cfg_instance) * 2 + 1; + sizeof(clli->cfg_instance) * 2 + 4; OBD_ALLOC(inst_name, inst_len); if (inst_name == NULL) GOTO(out, rc = -ENOMEM);