Skip to content

Commit 6b51737

Browse files
vishalsdkdavem330
authored andcommitted
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: 94cdb8b ("cxgb4: Add support for dynamic allocation of resources for ULD") Signed-off-by: Shahjada Abul Husain <[email protected]> Signed-off-by: Vishal Kulkarni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8ae72cb commit 6b51737

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,12 @@ static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
137137
static int alloc_uld_rxqs(struct adapter *adap,
138138
struct sge_uld_rxq_info *rxq_info, bool lro)
139139
{
140-
struct sge *s = &adap->sge;
141140
unsigned int nq = rxq_info->nrxq + rxq_info->nciq;
141+
int i, err, msi_idx, que_idx = 0, bmap_idx = 0;
142142
struct sge_ofld_rxq *q = rxq_info->uldrxq;
143143
unsigned short *ids = rxq_info->rspq_id;
144-
unsigned int bmap_idx = 0;
144+
struct sge *s = &adap->sge;
145145
unsigned int per_chan;
146-
int i, err, msi_idx, que_idx = 0;
147146

148147
per_chan = rxq_info->nrxq / adap->params.nports;
149148

@@ -161,6 +160,10 @@ static int alloc_uld_rxqs(struct adapter *adap,
161160

162161
if (msi_idx >= 0) {
163162
bmap_idx = get_msix_idx_from_bmap(adap);
163+
if (bmap_idx < 0) {
164+
err = -ENOSPC;
165+
goto freeout;
166+
}
164167
msi_idx = adap->msix_info_ulds[bmap_idx].idx;
165168
}
166169
err = t4_sge_alloc_rxq(adap, &q->rspq, false,

0 commit comments

Comments
 (0)