Skip to content

Commit b61b04a

Browse files
Denis Bolotindavem330
authored andcommitted
qed: Fix the doorbell address sanity check
Fix the condition which verifies that doorbell address is inside the doorbell bar by checking that the end of the address is within range as well. Signed-off-by: Denis Bolotin <[email protected]> Signed-off-by: Michal Kalderon <[email protected]> Signed-off-by: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9ac6bb1 commit b61b04a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/net/ethernet/qlogic/qed/qed_dev.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,15 @@ static void qed_db_recovery_dp_entry(struct qed_hwfn *p_hwfn,
102102

103103
/* Doorbell address sanity (address within doorbell bar range) */
104104
static bool qed_db_rec_sanity(struct qed_dev *cdev,
105-
void __iomem *db_addr, void *db_data)
105+
void __iomem *db_addr,
106+
enum qed_db_rec_width db_width,
107+
void *db_data)
106108
{
109+
u32 width = (db_width == DB_REC_WIDTH_32B) ? 32 : 64;
110+
107111
/* Make sure doorbell address is within the doorbell bar */
108112
if (db_addr < cdev->doorbells ||
109-
(u8 __iomem *)db_addr >
113+
(u8 __iomem *)db_addr + width >
110114
(u8 __iomem *)cdev->doorbells + cdev->db_size) {
111115
WARN(true,
112116
"Illegal doorbell address: %p. Legal range for doorbell addresses is [%p..%p]\n",
@@ -159,7 +163,7 @@ int qed_db_recovery_add(struct qed_dev *cdev,
159163
}
160164

161165
/* Sanitize doorbell address */
162-
if (!qed_db_rec_sanity(cdev, db_addr, db_data))
166+
if (!qed_db_rec_sanity(cdev, db_addr, db_width, db_data))
163167
return -EINVAL;
164168

165169
/* Obtain hwfn from doorbell address */
@@ -205,10 +209,6 @@ int qed_db_recovery_del(struct qed_dev *cdev,
205209
return 0;
206210
}
207211

208-
/* Sanitize doorbell address */
209-
if (!qed_db_rec_sanity(cdev, db_addr, db_data))
210-
return -EINVAL;
211-
212212
/* Obtain hwfn from doorbell address */
213213
p_hwfn = qed_db_rec_find_hwfn(cdev, db_addr);
214214

@@ -317,7 +317,7 @@ static void qed_db_recovery_ring(struct qed_hwfn *p_hwfn,
317317

318318
/* Sanity */
319319
if (!qed_db_rec_sanity(p_hwfn->cdev, db_entry->db_addr,
320-
db_entry->db_data))
320+
db_entry->db_width, db_entry->db_data))
321321
return;
322322

323323
/* Flush the write combined buffer. Since there are multiple doorbelling

0 commit comments

Comments
 (0)