Skip to content

Commit

Permalink
PR #60221: Fix null pointer dereference in tsl::profiler::CreateStub
Browse files Browse the repository at this point in the history
Imported from GitHub PR tensorflow/tensorflow#60221

The bug was found by Svace static analyzer:

1. channel may be null
2. it is passed to grpc::ProfileAnalysis::NewStub(channel)
3. then passed to grpc::ProfileAnalysis::Stub::Stub(channel)
4. then constructor grpc::internal::RpcMethod::RpcMethod() dereferences channel via channel->RegisterMethod(name)

cc @mihaimaruseac
Copybara import of the project:

--
232683a9b9e567f43239592b958e4302c257d85d by Alexey Vishnyakov <vishnya@ispras.ru>:

Fix null pointer dereference in tsl::profiler::CreateStub

The bug was found by Svace static analyzer:

1. channel may be null
2. it is passed to grpc::ProfileAnalysis::NewStub(channel)
3. then passed to grpc::ProfileAnalysis::Stub::Stub(channel)
4. then constructor grpc::internal::RpcMethod::RpcMethod() dereferences
   channel via channel->RegisterMethod(name)

Merging this change closes #60221

PiperOrigin-RevId: 523138447
  • Loading branch information
SweetVishnya authored and Copybara-Service committed Apr 10, 2023
1 parent 3f88aaa commit d5ace5b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions third_party/tsl/tsl/profiler/rpc/client/profiler_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ std::unique_ptr<typename T::Stub> CreateStub(
service_address, ::grpc::InsecureChannelCredentials(), channel_args);
if (!channel) {
LOG(ERROR) << "Unable to create channel" << service_address;
return nullptr;
}
return T::NewStub(channel);
}
Expand Down

0 comments on commit d5ace5b

Please sign in to comment.