drivers/infiniband/core: Use a NULL test rather than an IS_ERR test
Subsystems (2)
PATCH 1/1 drivers/infiniband/core: Use a NULL test rather than an IS_ERR test
From: Julien Brunel <[email protected]>
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 = EIS_ERR(x)
// </smpl>
Signed-off-by Julien Brunel <[email protected]>
Signed-off-by Julia Lawall <[email protected]>
--- drivers/infiniband/core/ucma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/ucma.c +2 -2
@@ -904,8 +904,8 @@ static ssize_t ucma_join_multicast(strucmutex_lock (&file->mut); mc =ucma_alloc_multicast (ctx); -if (IS_ERR (mc)) { - ret =PTR_ERR (mc); +if (mc =NULL ) { + ret = -ENOMEM ; goto err1; }
Roland Dreier
Appliedthanks, applied