aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/qed
diff options
context:
space:
mode:
authorAlexander Lobakin <alobakin@marvell.com>2020-07-23 01:10:35 +0300
committerDavid S. Miller <davem@davemloft.net>2020-07-22 18:19:03 -0700
commit9b6ee3cf95d322ab02e9927f5b08ebc870ca9f1f (patch)
tree08bd8489f541676ab787ef9249beb2a925da2e7e /include/linux/qed
parentqed: prevent possible double-frees of the chains (diff)
downloadlinux-dev-9b6ee3cf95d322ab02e9927f5b08ebc870ca9f1f.tar.xz
linux-dev-9b6ee3cf95d322ab02e9927f5b08ebc870ca9f1f.zip
qed: sanitize PBL chains allocation
PBL chain elements are actually DMA addresses stored in __le64, but currently their size is hardcoded to 8, and DMA addresses are assigned via cast to variable-sized dma_addr_t without any bitwise conversions. Change the type of pbl_virt array to match the actual one, add a new field to store the size of allocated DMA memory and sanitize elements assignment. Misc: give more logic names to the members of qed_chain::pbl_sp embedded struct. Signed-off-by: Alexander Lobakin <alobakin@marvell.com> Signed-off-by: Igor Russkikh <irusskikh@marvell.com> Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/qed')
-rw-r--r--include/linux/qed/qed_chain.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h
index 087073517c09..265e0b671a5c 100644
--- a/include/linux/qed/qed_chain.h
+++ b/include/linux/qed/qed_chain.h
@@ -127,8 +127,9 @@ struct qed_chain {
/* Base address of a pre-allocated buffer for pbl */
struct {
- dma_addr_t p_phys_table;
- void *p_virt_table;
+ __le64 *table_virt;
+ dma_addr_t table_phys;
+ size_t table_size;
} pbl_sp;
/* Address of first page of the chain - the address is required
@@ -146,7 +147,6 @@ struct qed_chain {
bool b_external_pbl;
};
-#define QED_CHAIN_PBL_ENTRY_SIZE 8
#define QED_CHAIN_PAGE_SIZE 0x1000
#define ELEMS_PER_PAGE(elem_size) \
@@ -236,7 +236,7 @@ static inline u32 qed_chain_get_page_cnt(struct qed_chain *p_chain)
static inline dma_addr_t qed_chain_get_pbl_phys(struct qed_chain *p_chain)
{
- return p_chain->pbl_sp.p_phys_table;
+ return p_chain->pbl_sp.table_phys;
}
/**
@@ -527,8 +527,8 @@ static inline void qed_chain_init_params(struct qed_chain *p_chain,
p_chain->capacity = p_chain->usable_per_page * page_cnt;
p_chain->size = p_chain->elem_per_page * page_cnt;
- p_chain->pbl_sp.p_phys_table = 0;
- p_chain->pbl_sp.p_virt_table = NULL;
+ p_chain->pbl_sp.table_phys = 0;
+ p_chain->pbl_sp.table_virt = NULL;
p_chain->pbl.pp_addr_tbl = NULL;
}
@@ -569,8 +569,8 @@ static inline void qed_chain_init_pbl_mem(struct qed_chain *p_chain,
dma_addr_t p_phys_pbl,
struct addr_tbl_entry *pp_addr_tbl)
{
- p_chain->pbl_sp.p_phys_table = p_phys_pbl;
- p_chain->pbl_sp.p_virt_table = p_virt_pbl;
+ p_chain->pbl_sp.table_phys = p_phys_pbl;
+ p_chain->pbl_sp.table_virt = p_virt_pbl;
p_chain->pbl.pp_addr_tbl = pp_addr_tbl;
}