libese, libese-hw: better check for error states.
If a device is in error, do not let other commands
proceed.
Additionally, nq-nci needed to better check its
handle state.
Test: booted with a bad device and esed doesn't NULL deref.
Bug: none
Change-Id: I3bceda76f4ce84f95f4128c04e26dbd051972cc5
diff --git a/libese/ese.c b/libese/ese.c
index 55eb838..01c5345 100644
--- a/libese/ese.c
+++ b/libese/ese.c
@@ -40,6 +40,8 @@
return -1;
}
ALOGV("opening interface '%s'", ese_name(ese));
+ ese->error.is_err = false;
+ ese->error.code = 0;
if (ese->ops->open) {
return ese->ops->open(ese, hw_opts);
}
@@ -100,7 +102,9 @@
if (!ese) {
return -1;
}
-
+ if (ese->error.is_err) {
+ return -1;
+ }
if (ese->ops->transceive) {
recvd = ese->ops->transceive(ese, tx_bufs, tx_segs, rx_bufs, rx_segs);
return ese_error(ese) ? -1 : recvd;