Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1331410

[PATCH 2/5] staging/lustre/obdecho: Better handle invalid create requests

From green@linuxhacker.ru
Newsgroups linux.kernel
Subject [PATCH 2/5] staging/lustre/obdecho: Better handle invalid create requests
Date 2016-02-10 19:10 +0100
Message-ID <r0Hnd-5O7-33@gated-at.bofh.it> (permalink)
References <r0Hnc-5O7-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Oleg Drokin <green@linuxhacker.ru>

When gettng an invalid create request in echo code (wrong group,
or no group at all), just return an error instead of crashing.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/obdecho/echo_client.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index e1c9d11..4ca82af 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -1210,8 +1210,10 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
 	int		     rc;
 	int		     created = 0;
 
-	if ((oa->o_valid & OBD_MD_FLID) == 0) { /* no obj id */
-		CERROR("No valid oid\n");
+	if (!(oa->o_valid & OBD_MD_FLID) ||
+	    !(oa->o_valid & OBD_MD_FLGROUP) ||
+	    !fid_seq_is_echo(ostid_seq(&oa->o_oi))) {
+		CERROR("invalid oid " DOSTID "\n", POSTID(&oa->o_oi));
 		return -EINVAL;
 	}
 
@@ -1222,16 +1224,11 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
 	}
 
 	/* setup object ID here */
-	LASSERT(oa->o_valid & OBD_MD_FLGROUP);
 	lsm->lsm_oi = oa->o_oi;
 
 	if (ostid_id(&lsm->lsm_oi) == 0)
 		ostid_set_id(&lsm->lsm_oi, ++last_object_id);
 
-	/* Only echo objects are allowed to be created */
-	LASSERT((oa->o_valid & OBD_MD_FLGROUP) &&
-		(ostid_seq(&oa->o_oi) == FID_SEQ_ECHO));
-
 	rc = obd_create(env, ec->ec_exp, oa, &lsm, oti);
 	if (rc != 0) {
 		CERROR("Cannot create objects: rc = %d\n", rc);
-- 
2.1.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] Few misc Lustre fixes green@linuxhacker.ru - 2016-02-10 19:10 +0100
  [PATCH 5/5] staging/lustre: Remove unused LUSTRE_VERSION_ALLOWED_OFFSET define green@linuxhacker.ru - 2016-02-10 19:10 +0100
  [PATCH 3/5] staging/lustre: Adjust import state history output format green@linuxhacker.ru - 2016-02-10 19:10 +0100
  [PATCH 2/5] staging/lustre/obdecho: Better handle invalid create requests green@linuxhacker.ru - 2016-02-10 19:10 +0100
  [PATCH 4/5] staging/lustre: Update internal client version. green@linuxhacker.ru - 2016-02-10 19:10 +0100

csiph-web