]> Git Repo - linux.git/commitdiff
RDMA/ucma: Test ucma_alloc_multicast() return against NULL, not with IS_ERR()
authorJulien Brunel <[email protected]>
Fri, 10 Oct 2008 19:00:19 +0000 (12:00 -0700)
committerRoland Dreier <[email protected]>
Fri, 10 Oct 2008 19:00:19 +0000 (12:00 -0700)
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 <[email protected]>
Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Roland Dreier <[email protected]>
drivers/infiniband/core/ucma.c

index 3ddacf39b7ba50e1d9de4378ca2544b7637488fc..4346a24568fb74746a74a12b2b1f534f23f1731f 100644 (file)
@@ -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;
        }
 
This page took 0.058729 seconds and 4 git commands to generate.