From: "Maxin B. John" <maxin.john@gmail.com>
To: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Cc: gregkh@linuxfoundation.org, andreas.dilger@intel.com,
josh@joshtriplett.org, bergwolf@gmail.com,
dulshani.gunawardhana89@gmail.com, jinshan.xiong@intel.com,
alexey.zhuravlev@intel.com, "Maxin B. John" <maxin.john@enea.com>
Subject: [PATCH 1/2] lustre/mdc_lib: fix possible null pointer dereference
Date: Wed, 5 Mar 2014 14:04:35 +0100 [thread overview]
Message-ID: <1394024676-35160-1-git-send-email-maxin.john@enea.com> (raw)
From: "Maxin B. John" <maxin.john@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.john@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
next reply other threads:[~2014-03-05 13:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-05 13:04 Maxin B. John [this message]
2014-03-05 13:04 ` [PATCH 2/2] lustre/lov_obd: " Maxin B. John
2014-03-06 19:53 ` Greg KH
2014-03-05 18:53 ` [PATCH 1/2] lustre/mdc_lib: " Dan Carpenter
2014-03-06 19:51 ` Greg KH
2014-03-06 21:41 ` Maxin B. John
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394024676-35160-1-git-send-email-maxin.john@enea.com \
--to=maxin.john@gmail.com \
--cc=alexey.zhuravlev@intel.com \
--cc=andreas.dilger@intel.com \
--cc=bergwolf@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=dulshani.gunawardhana89@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jinshan.xiong@intel.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxin.john@enea.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®