Fix to reallocate fd when gatt write fails