diff options
author | Anton Vasilyev <vasilyev@ispras.ru> | 2017-08-11 15:57:22 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-12 00:56:23 +0300 |
commit | 54a6a043fb8580d5a741774669ef6049f402f228 (patch) | |
tree | 9632f50edc83f47ea18ef6011af1cafec141dc8b /drivers/isdn/mISDN/layer2.c | |
parent | bb3afda4fc4ea690ff92a36eef4c0afe4d19da04 (diff) | |
download | linux-54a6a043fb8580d5a741774669ef6049f402f228.tar.xz |
mISDN: Fix null pointer dereference at mISDN_FsmNew
If mISDN_FsmNew() fails to allocate memory for jumpmatrix
then null pointer dereference will occur on any write to
jumpmatrix.
The patch adds check on successful allocation and
corresponding error handling.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/mISDN/layer2.c')
-rw-r--r-- | drivers/isdn/mISDN/layer2.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/isdn/mISDN/layer2.c b/drivers/isdn/mISDN/layer2.c index 7243a6746f8b..9ff0903a0e89 100644 --- a/drivers/isdn/mISDN/layer2.c +++ b/drivers/isdn/mISDN/layer2.c @@ -2247,15 +2247,26 @@ static struct Bprotocol X75SLP = { int Isdnl2_Init(u_int *deb) { + int res; debug = deb; mISDN_register_Bprotocol(&X75SLP); l2fsm.state_count = L2_STATE_COUNT; l2fsm.event_count = L2_EVENT_COUNT; l2fsm.strEvent = strL2Event; l2fsm.strState = strL2State; - mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList)); - TEIInit(deb); + res = mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList)); + if (res) + goto error; + res = TEIInit(deb); + if (res) + goto error_fsm; return 0; + +error_fsm: + mISDN_FsmFree(&l2fsm); +error: + mISDN_unregister_Bprotocol(&X75SLP); + return res; } void |