Commit 6b517374 authored by Vishal Kulkarni's avatar Vishal Kulkarni Committed by David S. Miller

cxgb4:Fix out-of-bounds MSI-X info array access

When fetching free MSI-X vectors for ULDs, check for the error code
before accessing MSI-X info array. Otherwise, an out-of-bounds access is
attempted, which results in kernel panic.

Fixes: 94cdb8bb ("cxgb4: Add support for dynamic allocation of resources for ULD")
Signed-off-by: default avatarShahjada Abul Husain <shahjada@chelsio.com>
Signed-off-by: default avatarVishal Kulkarni <vishal@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8ae72cbf
...@@ -137,13 +137,12 @@ static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp, ...@@ -137,13 +137,12 @@ static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
static int alloc_uld_rxqs(struct adapter *adap, static int alloc_uld_rxqs(struct adapter *adap,
struct sge_uld_rxq_info *rxq_info, bool lro) struct sge_uld_rxq_info *rxq_info, bool lro)
{ {
struct sge *s = &adap->sge;
unsigned int nq = rxq_info->nrxq + rxq_info->nciq; unsigned int nq = rxq_info->nrxq + rxq_info->nciq;
int i, err, msi_idx, que_idx = 0, bmap_idx = 0;
struct sge_ofld_rxq *q = rxq_info->uldrxq; struct sge_ofld_rxq *q = rxq_info->uldrxq;
unsigned short *ids = rxq_info->rspq_id; unsigned short *ids = rxq_info->rspq_id;
unsigned int bmap_idx = 0; struct sge *s = &adap->sge;
unsigned int per_chan; unsigned int per_chan;
int i, err, msi_idx, que_idx = 0;
per_chan = rxq_info->nrxq / adap->params.nports; per_chan = rxq_info->nrxq / adap->params.nports;
...@@ -161,6 +160,10 @@ static int alloc_uld_rxqs(struct adapter *adap, ...@@ -161,6 +160,10 @@ static int alloc_uld_rxqs(struct adapter *adap,
if (msi_idx >= 0) { if (msi_idx >= 0) {
bmap_idx = get_msix_idx_from_bmap(adap); bmap_idx = get_msix_idx_from_bmap(adap);
if (bmap_idx < 0) {
err = -ENOSPC;
goto freeout;
}
msi_idx = adap->msix_info_ulds[bmap_idx].idx; msi_idx = adap->msix_info_ulds[bmap_idx].idx;
} }
err = t4_sge_alloc_rxq(adap, &q->rspq, false, err = t4_sge_alloc_rxq(adap, &q->rspq, false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment