Microchip-Ethernet / EVB-KSZ9477

Repository for using Microchip EVB-KSZ9477 board. Product Supported: KSZ9477, KSZ9567, KSZ9897, KSZ9896, KSZ8567, KSZ8565, KSZ9893, KSZ9563, KSZ8563, LAN9646, Phys(KSZ9031/9131, LAN8770
76 stars 78 forks source link

sw_get_br_id() returns ptr to stack (invalid after return) #16

Open mads-bn opened 5 years ago

mads-bn commented 5 years ago

sw_get_br_id() should not return a pointer to "id" located on the stack (invalid after return). This will also fix a compile warning (want all source to compile without warnings). My local fix is to change "id" to a static but it assumes that only one thread executes this at a time (likely to be ok).

+--- a/drivers/net/ethernet/micrel/ksz_sw_9897.c
++++ b/drivers/net/ethernet/micrel/ksz_sw_9897.c
+@@ -13119,7 +13119,7 @@ static void sw_free_fid(struct ksz_sw *sw, u16 fid)
+ 
+ static const u8 *sw_get_br_id(struct ksz_sw *sw)
+ {
+-      u8 id[8];
++      static u8 id[8];
+       const u8* ret = id;
+ 
+       memcpy(&id[2], sw->info->mac_addr, ETH_ALEN);

https://github.com/Microchip-Ethernet/EVB-KSZ9477/blob/d7129fdf2b582ff7e25c63e458cc60dd4739226f/KSZ/linux-drivers/ksz9897/linux-4.14/drivers/net/ethernet/micrel/ksz_sw_9897.c#L13122