]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ice: use stack variable for virtchnl_supported_rxdids
authorJacob Keller <jacob.e.keller@intel.com>
Mon, 9 Sep 2024 23:05:44 +0000 (16:05 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Wed, 13 Nov 2024 18:30:21 +0000 (10:30 -0800)
commiteaa3e9876bbc2f260cf17167a194bd412e80f177
treec19e08e87e2037006947024c1ebeb248a62392d3
parent8cca16be5efc6a481487e34a0fe542cc480fc720
ice: use stack variable for virtchnl_supported_rxdids

The ice_vc_query_rxdid() function allocates memory to store the
virtchnl_supported_rxdids structure used to communicate the bitmap of
supported RXDIDs to a VF.

This structure is only 8 bytes in size. The function must hold the
allocated length on the stack as well as the pointer to the structure which
itself is 8 bytes. Allocating this storage on the heap adds unnecessary
overhead including a potential error path that must be handled in case
kzalloc fails. Because this structure is so small, we're not saving stack
space. Additionally, because we must ensure that we free the allocated
memory, the return value from ice_vc_send_msg_to_vf() must also be saved in
the stack ret variable. Depending on compiler optimization, this means
allocating the 8-byte structure is requiring up to 16-bytes of stack
memory!

Simplify this function to keep the rxdid variable on the stack, saving
memory and removing a potential failure exit path from this function.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_virtchnl.c