Whamcloud - gitweb
LU-7412 osp_md_read() may pass an ERR_PTR() to osp_update_request_destroy() 22/17522/3
authorakam <azurelustre@gmail.com>
Wed, 9 Dec 2015 07:59:53 +0000 (13:29 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 9 Jan 2016 00:10:11 +0000 (00:10 +0000)
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 <azurelustre@gmail.com>
Reviewed-on: http://review.whamcloud.com/17522
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
lustre/osp/osp_md_object.c

index 643e31a..38b4634 100644 (file)
@@ -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);
 }