From cee1ab3997d70ee5eeece41b50fbe4479eda9d14 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 30 Jan 2013 16:32:27 +0100 Subject: [PATCH] LU-2710 build: avoid function resolution mistakes by Coverity Remove function resolution mistakes made by Coverity version 6.0.3. The .hs_keycmp function is incorrectly resolved by Coverity, making the variable passed as its first 'key' parameter to be considered of the wrong type. Data structures being of different sizes, it ends up with this Coverity defect: Out-of-bounds access (OVERRUN_STATIC) Overrunning static array by passing it as an argument to a function which indexes it at a higher byte position. Signed-off-by: Sebastien Buisson Change-Id: Ie062b05a73db16d63c63db89dc4d0e264f3b1f8a Reviewed-on: http://review.whamcloud.com/5211 Tested-by: Hudson Reviewed-by: Keith Mannthey Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lod/lod_lov.c | 9 +++++++++ lustre/lod/lod_qos.c | 3 +++ lustre/obdecho/echo_client.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 1d6986b..d477c88 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -700,6 +700,9 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo, nd = &OST_TGT(md,idx)->ltd_ost->dd_lu_dev; lod_putref(md, &md->lod_ost_descs); + /* In the function below, .hs_keycmp resolves to + * u_obj_hop_keycmp() */ + /* coverity[overrun-buffer-val] */ o = lu_object_find_at(env, nd, &info->lti_fid, NULL); if (IS_ERR(o)) GOTO(out, rc = PTR_ERR(o)); @@ -865,6 +868,9 @@ int lod_verify_striping(struct lod_device *d, const struct lu_buf *buf, v3 = buf->lb_buf; if (v3) + /* In the function below, .hs_keycmp resolves to + * pool_hashkey_keycmp() */ + /* coverity[overrun-buffer-val] */ pool = lod_find_pool(d, v3->lmm_pool_name); if (pool != NULL) { @@ -1036,6 +1042,9 @@ int lod_pools_fini(struct lod_device *lod) pool = cfs_list_entry(pos, struct pool_desc, pool_list); /* free pool structs */ CDEBUG(D_INFO, "delete pool %p\n", pool); + /* In the function below, .hs_keycmp resolves to + * pool_hashkey_keycmp() */ + /* coverity[overrun-buffer-val] */ lod_pool_del(obd, pool->pool_name); } diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index af0f9db..b1aa0c1 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -1315,6 +1315,9 @@ static int lod_qos_parse_config(const struct lu_env *env, v3 = buf->lb_buf; lod_object_set_pool(lo, v3->lmm_pool_name); + /* In the function below, .hs_keycmp resolves to + * pool_hashkey_keycmp() */ + /* coverity[overrun-buffer-val] */ pool = lod_find_pool(d, v3->lmm_pool_name); if (pool != NULL) { if (lo->ldo_def_stripe_offset != diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index a8f5b0b..fda4d54 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1748,6 +1748,9 @@ static struct lu_object *echo_md_lookup(const struct lu_env *env, RETURN(ERR_PTR(rc)); } + /* In the function below, .hs_keycmp resolves to + * lu_obj_hop_keycmp() */ + /* coverity[overrun-buffer-val] */ child = lu_object_find_at(env, &ed->ed_cl.cd_lu_dev, fid, NULL); RETURN(child); @@ -2041,6 +2044,9 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, RETURN(ERR_PTR(rc)); } + /* In the function below, .hs_keycmp resolves to + * lu_obj_hop_keycmp() */ + /* coverity[overrun-buffer-val] */ parent = lu_object_find_at(env, &ed->ed_cl.cd_lu_dev, fid, NULL); if (IS_ERR(parent)) { CERROR("Can not find the parent "DFID": rc = %ld\n", -- 1.8.3.1