]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
iflib: fix dangling device softc pointer
authorerj <erj@FreeBSD.org>
Wed, 24 Jul 2019 21:43:41 +0000 (21:43 +0000)
committererj <erj@FreeBSD.org>
Wed, 24 Jul 2019 21:43:41 +0000 (21:43 +0000)
commit9bf94a50911bfe65490f641a53dc4b2945f8a42a
tree0acc48e76c693ec1ed899248096eecf24a64995c
parentb7fc72efad1be164e22d4f839e4fe9ae4c56364c
iflib: fix dangling device softc pointer

Commit text by Jake:
If a driver's IFDI_ATTACH_PRE function fails, the iflib_device_register
function will free the ctx pointer. However, it does not reset the
device softc pointer to NULL.

This will result in memory corruption as a future access to the now
invalid pointer will corrupt memory that is later allocated on top of
the same memory location.

The iflib_device_deregister function correctly resets the softc pointer
by using device_set_softc().

This clears up the invalid dangling pointer and prevents memory
corruption that could lead to a panic or undefined behavior if the
device's driver failed to attach.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: erj@, gallatin@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21003
sys/net/iflib.c