From c05ad2200fff64e67a699c0c1346d60a3bc3d6c3 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 27 Mar 2017 11:32:58 +0300 Subject: [PATCH] xpp: fix chip/ports numbers sanity test The test originally did not check any input from the hardware. Fix it to check the actual (and proper) input from the hardware. Signed-off-by: Tzafrir Cohen --- drivers/dahdi/xpp/card_bri.c | 12 ++++++++++-- drivers/dahdi/xpp/card_pri.c | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c index 302e741..40578e5 100644 --- a/drivers/dahdi/xpp/card_bri.c +++ b/drivers/dahdi/xpp/card_bri.c @@ -693,8 +693,16 @@ static xpd_t *BRI_card_new(xbus_t *xbus, int unit, int subunit, xpd_t *xpd = NULL; int channels = min(3, CHANNELS_PERXPD); - if (unit_descriptor->ports_per_chip != 1) { - XBUS_ERR(xbus, "Bad subunit_ports=%d\n", unit_descriptor->ports_per_chip); + if ((unit_descriptor->ports_per_chip < 1) || + (unit_descriptor->ports_per_chip > 4)) { + XBUS_ERR(xbus, "Bad ports_per_chip=%d\n", + unit_descriptor->ports_per_chip); + return NULL; + } + if ((unit_descriptor->numchips) < 1 || + (unit_descriptor->numchips > 2)) { + XBUS_ERR(xbus, "Bad numchips=%d\n", + unit_descriptor->numchips); return NULL; } XBUS_DBG(GENERAL, xbus, "\n"); diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c index 3393f44..e8ed410 100644 --- a/drivers/dahdi/xpp/card_pri.c +++ b/drivers/dahdi/xpp/card_pri.c @@ -1264,8 +1264,15 @@ static xpd_t *PRI_card_new(xbus_t *xbus, int unit, int subunit, struct PRI_priv_data *priv; int channels = min(31, CHANNELS_PERXPD); /* worst case */ - if (unit_descriptor->ports_per_chip != 1) { - XBUS_ERR(xbus, "Bad subunit_ports=%d\n", unit_descriptor->ports_per_chip); + if ((unit_descriptor->ports_per_chip < 1) || + (unit_descriptor->ports_per_chip > 4)) { + XBUS_ERR(xbus, "Bad ports_per_chip=%d\n", + unit_descriptor->ports_per_chip); + return NULL; + } + if (unit_descriptor->numchips != 1) { + XBUS_ERR(xbus, "Bad numchips=%d\n", + unit_descriptor->numchips); return NULL; } XBUS_DBG(GENERAL, xbus, "\n");