Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31d71980 authored by Yun-Hao Chung's avatar Yun-Hao Chung
Browse files

Floss: Ignore multiple RemoteHostSupportedFeatureNotifications

It is observed that the host controller can receive multiple Remote Host
Supported Feature Notification events during Remote Name Request stage.
This causes a crash since the callback function is BindOnce. Although we
are not sure if this is a controller error, peer devcie's fault, or IOP
issue, it should be harmeless to just ignore the second feature
notification and proceed the RNR.

Bug: 29698044
Test: mma -j32
Test: intentionally to invoke
on_remote_host_supported_features_notification twice and make sure there
is no crash.
Tag: #floss

Change-Id: I17770b49e60e719fbeedae81eac88dc5c6b45ab1
parent 784078c7
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -156,15 +156,21 @@ struct RemoteNameRequestModule::impl {
  void on_remote_host_supported_features_notification(EventView view) {
    auto packet = RemoteHostSupportedFeaturesNotificationView::Create(view);
    ASSERT(packet.IsValid());
    if (pending_) {
    if (pending_ && !on_remote_host_supported_features_notification_.IsEmpty()) {
      LOG_INFO(
          "Received REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION from %s",
          packet.GetBdAddr().ToRedactedStringForLogging().c_str());
      on_remote_host_supported_features_notification_.Invoke(packet.GetHostSupportedFeatures());
    } else {
      // Remove the callback so that we won't call it again.
      on_remote_host_supported_features_notification_ = RemoteHostSupportedFeaturesCallback();
    } else if (!pending_) {
      LOG_ERROR(
          "Received unexpected REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION when no Remote Name "
          "Request is outstanding");
    } else {  // callback is not set, which indicates we have processed the feature notification.
      LOG_ERROR(
          "Received more than one REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION during Remote Name "
          "Request");
    }
  }