Commit 0629a330 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

qed: avoid possible stack overflow in qed_ll2_acquire_connection

struct qed_ll2_info is rather large, so putting it on the stack
can cause an overflow, as this warning tries to tell us:

drivers/net/ethernet/qlogic/qed/qed_ll2.c: In function 'qed_ll2_start':
drivers/net/ethernet/qlogic/qed/qed_ll2.c:2159:1: error: the frame size of 1056 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

qed_ll2_start_ooo() already uses a dynamic allocation for the structure
to work around that problem, and we could do the same in qed_ll2_start()
as well as qed_roce_ll2_start(), but since the structure is only
used to pass a couple of initialization values here, it seems nicer
to replace it with a different structure.

Lacking any idea for better naming, I'm adding 'struct qed_ll2_conn',
which now contains all the initialization data, and this now simply
gets copied into struct qed_ll2_info rather than assigning all members
one by one.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarYuval Mintz <Yuval.Mintz@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 91e74465
This diff is collapsed.
...@@ -112,15 +112,8 @@ struct qed_ll2_tx_queue { ...@@ -112,15 +112,8 @@ struct qed_ll2_tx_queue {
bool b_completing_packet; bool b_completing_packet;
}; };
struct qed_ll2_info { struct qed_ll2_conn {
/* Lock protecting the state of LL2 */
struct mutex mutex;
enum qed_ll2_conn_type conn_type; enum qed_ll2_conn_type conn_type;
u32 cid;
u8 my_id;
u8 queue_id;
u8 tx_stats_id;
bool b_active;
u16 mtu; u16 mtu;
u8 rx_drop_ttl0_flg; u8 rx_drop_ttl0_flg;
u8 rx_vlan_removal_en; u8 rx_vlan_removal_en;
...@@ -128,10 +121,21 @@ struct qed_ll2_info { ...@@ -128,10 +121,21 @@ struct qed_ll2_info {
enum core_tx_dest tx_dest; enum core_tx_dest tx_dest;
enum core_error_handle ai_err_packet_too_big; enum core_error_handle ai_err_packet_too_big;
enum core_error_handle ai_err_no_buf; enum core_error_handle ai_err_no_buf;
u8 gsi_enable;
};
struct qed_ll2_info {
/* Lock protecting the state of LL2 */
struct mutex mutex;
struct qed_ll2_conn conn;
u32 cid;
u8 my_id;
u8 queue_id;
u8 tx_stats_id;
bool b_active;
u8 tx_stats_en; u8 tx_stats_en;
struct qed_ll2_rx_queue rx_queue; struct qed_ll2_rx_queue rx_queue;
struct qed_ll2_tx_queue tx_queue; struct qed_ll2_tx_queue tx_queue;
u8 gsi_enable;
}; };
/** /**
...@@ -149,7 +153,7 @@ struct qed_ll2_info { ...@@ -149,7 +153,7 @@ struct qed_ll2_info {
* @return 0 on success, failure otherwise * @return 0 on success, failure otherwise
*/ */
int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn, int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn,
struct qed_ll2_info *p_params, struct qed_ll2_conn *p_params,
u16 rx_num_desc, u16 rx_num_desc,
u16 tx_num_desc, u16 tx_num_desc,
u8 *p_connection_handle); u8 *p_connection_handle);
......
...@@ -2632,7 +2632,7 @@ static int qed_roce_ll2_start(struct qed_dev *cdev, ...@@ -2632,7 +2632,7 @@ static int qed_roce_ll2_start(struct qed_dev *cdev,
{ {
struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
struct qed_roce_ll2_info *roce_ll2; struct qed_roce_ll2_info *roce_ll2;
struct qed_ll2_info ll2_params; struct qed_ll2_conn ll2_params;
int rc; int rc;
if (!params) { if (!params) {
......
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