]> git.baikalelectronics.ru Git - kernel.git/commit
bnxt_en: Fix memory fault in bnxt_ethtool_init()
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Thu, 19 Apr 2018 07:16:16 +0000 (03:16 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Apr 2018 20:35:09 +0000 (16:35 -0400)
commit24badf7957f81fe15ac82e462c953af0c853f72a
tree2c5c1171a5ef972cb5668b38bbafe038d06a3df6
parentdabc753d328d7509587fb991e059e474cd8756af
bnxt_en: Fix memory fault in bnxt_ethtool_init()

In some firmware images, the length of BNX_DIR_TYPE_PKG_LOG nvram type
could be greater than the fixed buffer length of 4096 bytes allocated by
the driver.  This was causing HWRM_NVM_READ to copy more data to the buffer
than the allocated size, causing general protection fault.

Fix the issue by allocating the exact buffer length returned by
HWRM_NVM_FIND_DIR_ENTRY, instead of 4096.  Move the kzalloc() call
into the bnxt_get_pkgver() function.

Fixes: bc8263a1815b ("bnxt_en: Add installed-package firmware version reporting via Ethtool GDRVINFO")
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt_nvm_defs.h