Skip to content

Commit 5ac188b

Browse files
Dan Carpentertorvalds
authored andcommitted
drivers/rapidio/rio_cm.c: fix potential oops in riocm_ch_listen()
If riocm_get_channel() fails, then we should just return -EINVAL. Calling riocm_put_channel() will trigger a NULL dereference and generally we should call put() if the get() didn't succeed. Link: http://lkml.kernel.org/r/20190110130230.GB27017@kadam Fixes: b6e8d4a ("rapidio: add RapidIO channelized messaging driver") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Matt Porter <[email protected]> Cc: Alexandre Bounine <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4b04700 commit 5ac188b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/rapidio/rio_cm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,9 @@ static int riocm_ch_listen(u16 ch_id)
12151215
riocm_debug(CHOP, "(ch_%d)", ch_id);
12161216

12171217
ch = riocm_get_channel(ch_id);
1218-
if (!ch || !riocm_cmp_exch(ch, RIO_CM_CHAN_BOUND, RIO_CM_LISTEN))
1218+
if (!ch)
1219+
return -EINVAL;
1220+
if (!riocm_cmp_exch(ch, RIO_CM_CHAN_BOUND, RIO_CM_LISTEN))
12191221
ret = -EINVAL;
12201222
riocm_put_channel(ch);
12211223
return ret;

0 commit comments

Comments
 (0)