From: anserper Date: Mon, 11 May 2009 19:14:51 +0000 (+0000) Subject: b=19115 X-Git-Tag: v1_8_2_01~1^2~459 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e547e2df49bd80f5023b6cc8d0e42f4cab62bfae;p=fs%2Flustre-release.git b=19115 i=Andreas Dilger i=Nathan Rutman additional error-checking in lov_setstripe --- diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index fffd848..d5c9996 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -424,19 +424,27 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp, rc = copy_from_user(&lumv3, lump, sizeof(struct lov_user_md_v1)); if (rc) RETURN(-EFAULT); - if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) || - (lumv1->lmm_magic == LOV_USER_MAGIC_V3_SWABBED)) { + + switch (lumv1->lmm_magic) { + case LOV_USER_MAGIC_V3_SWABBED: rc = copy_from_user(&lumv3, lump, sizeof(lumv3)); if (rc) - RETURN(-EFAULT); - } - - if ((lumv1->lmm_magic == LOV_USER_MAGIC_V1_SWABBED) || - (lumv1->lmm_magic == LOV_USER_MAGIC_V3_SWABBED)) { + break; + /* fall through to swab */ + case LOV_USER_MAGIC_V1_SWABBED: rc = lustre_swab_lov_user_md(lumv1); - if (rc) - RETURN(rc); + break; + case LOV_USER_MAGIC_V3: + rc = copy_from_user(&lumv3, lump, sizeof(lumv3)); + /* fall through */ + case LOV_USER_MAGIC_V1: + break; + default: + CERROR("bad lsm magic %08x\n", lumv1->lmm_magic); + RETURN(-EINVAL); } + if (rc) + RETURN(rc); /* in the rest of the tests, as *lumv1 and lumv3 have the same * fields, we use lumv1 to avoid code duplication */