Skip to content

Commit

Permalink
librbd/internal.cc: check earlier for null pointer
Browse files Browse the repository at this point in the history
Fix potential null ponter deref, move check for 'order != NULL'
to the beginning of the function to prevent a) deref in ldout() call
and b) to leave function as early as possible if check fails.

[src/librbd/internal.cc:843] -> [src/librbd/internal.cc:865]: (warning)
 Possible null pointer dereference: order - otherwise it is redundant
 to check it against null.

Signed-off-by: Danny Al-Gaaf <[email protected]>
  • Loading branch information
dalgaaf committed Jun 4, 2014
1 parent f17a963 commit 3ee3e66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/librbd/internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ namespace librbd {
bool old_format, uint64_t features, int *order,
uint64_t stripe_unit, uint64_t stripe_count)
{
if (!order)
return -EINVAL;

CephContext *cct = (CephContext *)io_ctx.cct();
ldout(cct, 20) << "create " << &io_ctx << " name = " << imgname
<< " size = " << size << " old_format = " << old_format
Expand All @@ -862,9 +865,6 @@ namespace librbd {
return -EEXIST;
}

if (!order)
return -EINVAL;

if (!*order)
*order = cct->_conf->rbd_default_order;
if (!*order)
Expand Down

0 comments on commit 3ee3e66

Please sign in to comment.