From bb4fb32a30943e04206a00789e694ec795f88d25 Mon Sep 17 00:00:00 2001 From: akam Date: Wed, 9 Dec 2015 13:29:53 +0530 Subject: [PATCH] LU-7412 osp_md_read() may pass an ERR_PTR() to osp_update_request_destroy() In osp_md_read() if osp_update_request_create() fails with ERR_PTR() it should return rather than passing on ERR_PTR() to the osp_update_request_destroy() Change-Id: Id4c0c5b3e0619a4e657c22bf27a5679e02164007 Signed-off-by: akam kumar bharathi Reviewed-on: http://review.whamcloud.com/17522 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: wangdi --- lustre/osp/osp_md_object.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index 643e31a..38b4634 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -1129,7 +1129,7 @@ static ssize_t osp_md_read(const struct lu_env *env, struct dt_object *dt, struct dt_device *dt_dev = &osp->opd_dt_dev; struct lu_buf *lbuf = &osp_env_info(env)->osi_lb2; char *ptr = rbuf->lb_buf; - struct osp_update_request *update = NULL; + struct osp_update_request *update; struct ptlrpc_request *req = NULL; struct out_read_reply *orr; struct ptlrpc_bulk_desc *desc; @@ -1145,7 +1145,7 @@ static ssize_t osp_md_read(const struct lu_env *env, struct dt_object *dt, * update_remote list of the thandle. */ update = osp_update_request_create(dt_dev); if (IS_ERR(update)) - GOTO(out, rc = PTR_ERR(update)); + RETURN(PTR_ERR(update)); rc = osp_update_rpc_pack(env, read, update, OUT_READ, lu_object_fid(&dt->do_lu), @@ -1153,13 +1153,13 @@ static ssize_t osp_md_read(const struct lu_env *env, struct dt_object *dt, if (rc != 0) { CERROR("%s: cannot insert update: rc = %d\n", dt_dev->dd_lu_dev.ld_obd->obd_name, rc); - GOTO(out, rc); + GOTO(out_update, rc); } rc = osp_prep_update_req(env, osp->opd_obd->u.cli.cl_import, update, &req); if (rc != 0) - GOTO(out, rc); + GOTO(out_update, rc); nbufs = (rbuf->lb_len + OUT_BULK_BUFFER_SIZE - 1) / OUT_BULK_BUFFER_SIZE; @@ -1220,11 +1220,10 @@ static ssize_t osp_md_read(const struct lu_env *env, struct dt_object *dt, rc = orr->orr_size; *pos = orr->orr_offset; out: - if (req != NULL) - ptlrpc_req_finished(req); + ptlrpc_req_finished(req); - if (update != NULL) - osp_update_request_destroy(update); +out_update: + osp_update_request_destroy(update); RETURN(rc); } -- 1.8.3.1