Skip to content

Commit

Permalink
block: sed-opal: "Never True" conditions
Browse files Browse the repository at this point in the history
'who' an unsigned variable in stucture opal_session_info
can never be lesser than zero. Hence, the condition
"who < OPAL_ADMIN1" can never be true.

Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Revanth Rajashekar authored and Jens Axboe committed Jun 29, 2019
1 parent 5e4c7cf commit 15ddffc
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions block/sed-opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2114,8 +2114,7 @@ static int opal_lock_unlock(struct opal_dev *dev,
{
int ret;

if (lk_unlk->session.who < OPAL_ADMIN1 ||
lk_unlk->session.who > OPAL_USER9)
if (lk_unlk->session.who > OPAL_USER9)
return -EINVAL;

mutex_lock(&dev->dev_lock);
Expand Down Expand Up @@ -2193,9 +2192,7 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
};
int ret;

if (opal_pw->session.who < OPAL_ADMIN1 ||
opal_pw->session.who > OPAL_USER9 ||
opal_pw->new_user_pw.who < OPAL_ADMIN1 ||
if (opal_pw->session.who > OPAL_USER9 ||
opal_pw->new_user_pw.who > OPAL_USER9)
return -EINVAL;

Expand Down

0 comments on commit 15ddffc

Please sign in to comment.