Skip to content

Commit

Permalink
RDMA/ucma: Test ucma_alloc_multicast() return against NULL, not with …
Browse files Browse the repository at this point in the history
…IS_ERR()

In case of error, the function ucma_alloc_multicast() returns a NULL
pointer, but never returns an ERR pointer.  So after a call to this
function, an IS_ERR test should be replaced by a NULL test.

The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@match bad_is_err_test@
expression x, E;
@@

x = ucma_alloc_multicast(...)
... when != x = E
IS_ERR(x)
// </smpl>

Signed-off-by:  Julien Brunel <brunel@diku.dk>
Signed-off-by:  Julia Lawall <julia@diku.dk>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Julien Brunel authored and Roland Dreier committed Oct 10, 2008
1 parent f6bccf6 commit 6aea938
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,8 @@ static ssize_t ucma_join_multicast(struct ucma_file *file,

mutex_lock(&file->mut);
mc = ucma_alloc_multicast(ctx);
if (IS_ERR(mc)) {
ret = PTR_ERR(mc);
if (!mc) {
ret = -ENOMEM;
goto err1;
}

Expand Down

0 comments on commit 6aea938

Please sign in to comment.