From: "Maxin B. John" <maxin.j...@enea.com>

cppcheck reported possible null pointer dereference in mdc_lib.c

[lustre/lustre/mdc/mdc_lib.c:233]: (error) Possible null pointer dereference
: op_data - otherwise it is redundant to check if op_data is null at line 226

Signed-off-by: Maxin B. John <maxin.j...@enea.com>
---
 drivers/staging/lustre/lustre/mdc/mdc_lib.c |   41 ++++++++++++++-------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c 
b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
index 91f6876..594e07c 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
@@ -223,29 +223,30 @@ void mdc_open_pack(struct ptlrpc_request *req, struct 
md_op_data *op_data,
        rec->cr_fsuid    = from_kuid(&init_user_ns, current_fsuid());
        rec->cr_fsgid    = from_kgid(&init_user_ns, current_fsgid());
        rec->cr_cap      = cfs_curproc_cap_pack();
+
        if (op_data != NULL) {
                rec->cr_fid1 = op_data->op_fid1;
                rec->cr_fid2 = op_data->op_fid2;
-       }
-       rec->cr_mode     = mode;
-       cr_flags = mds_pack_open_flags(flags, mode);
-       rec->cr_rdev     = rdev;
-       rec->cr_time     = op_data->op_mod_time;
-       rec->cr_suppgid1 = op_data->op_suppgids[0];
-       rec->cr_suppgid2 = op_data->op_suppgids[1];
-       rec->cr_bias     = op_data->op_bias;
-       rec->cr_umask    = current_umask();
-       rec->cr_old_handle = op_data->op_handle;
-
-       mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
-       /* the next buffer is child capa, which is used for replay,
-        * will be packed from the data in reply message. */
-
-       if (op_data->op_name) {
-               tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
-               LOGL0(op_data->op_name, op_data->op_namelen, tmp);
-               if (op_data->op_bias & MDS_CREATE_VOLATILE)
-                       cr_flags |= MDS_OPEN_VOLATILE;
+               rec->cr_mode     = mode;
+               cr_flags = mds_pack_open_flags(flags, mode);
+               rec->cr_rdev     = rdev;
+               rec->cr_time     = op_data->op_mod_time;
+               rec->cr_suppgid1 = op_data->op_suppgids[0];
+               rec->cr_suppgid2 = op_data->op_suppgids[1];
+               rec->cr_bias     = op_data->op_bias;
+               rec->cr_umask    = current_umask();
+               rec->cr_old_handle = op_data->op_handle;
+
+               mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
+               /* the next buffer is child capa, which is used for replay,
+               * will be packed from the data in reply message. */
+
+               if (op_data->op_name) {
+                       tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
+                       LOGL0(op_data->op_name, op_data->op_namelen, tmp);
+                       if (op_data->op_bias & MDS_CREATE_VOLATILE)
+                               cr_flags |= MDS_OPEN_VOLATILE;
+               }
        }
 
        if (lmm) {
-- 
1.7.10.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to