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

Commit a648bbf0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "libmodprobe: add missing locks in LoadWithAliases" into main

parents d27e3c4c ba17833f
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -458,14 +458,16 @@ bool Modprobe::InsmodWithDeps(const std::string& module_name, const std::string&

bool Modprobe::LoadWithAliases(const std::string& module_name, bool strict,
                               const std::string& parameters) {
    std::set<std::string> modules_to_load;
    bool module_loaded = false;
    {
        std::lock_guard guard(module_loaded_lock_);

        auto canonical_name = MakeCanonical(module_name);
        if (module_loaded_.count(canonical_name)) {
            return true;
        }

    std::set<std::string> modules_to_load = {canonical_name};
    bool module_loaded = false;

        modules_to_load.insert(std::move(canonical_name));
        // use aliases to expand list of modules to load (multiple modules
        // may alias themselves to the requested name)
        for (const auto& [alias, aliased_module] : module_aliases_) {
@@ -474,6 +476,7 @@ bool Modprobe::LoadWithAliases(const std::string& module_name, bool strict,
            if (module_loaded_.count(MakeCanonical(aliased_module))) continue;
            modules_to_load.emplace(aliased_module);
        }
    }

    // attempt to load all modules aliased to this name
    for (const auto& module : modules_to_load) {