Check if intf->cb->ec->destroy exists before calling it
Some systems use an EC destroy callback, for example, to close device
nodes in /dev. Currently this is the case for CrOS ECs which we
access via devfs.
However if platform setup is unsuccessful, for example if the CrOS
EC device node doesn't exist, then the destroy callback will still
be called and cause mosys to segfault.
(This is backported from CL:234042 for M39)
TEST=renamed /dev/cros_ec on nyan, ran mosys and it didn't segfault
Signed-off-by: David Hendricks <email@example.com>
Reviewed-by: Shawn Nematbakhsh <firstname.lastname@example.org>
3 files changed