With the current code flow, once the generic target is updated
target->registered is set and the remaining code is skipped.
So return immediately instead of going through the checks and
then skip.

Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Dave Jiang <[email protected]>
---
no changes
---
 drivers/acpi/numa/hmat.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
index 5a36d57289b4..1dc73d20d989 100644
--- a/drivers/acpi/numa/hmat.c
+++ b/drivers/acpi/numa/hmat.c
@@ -888,12 +888,13 @@ static void hmat_register_target(struct memory_target 
*target)
         * Register generic port perf numbers. The nid may not be
         * initialized and is still NUMA_NO_NODE.
         */
-       mutex_lock(&target_lock);
-       if (*(u16 *)target->gen_port_device_handle) {
-               hmat_update_generic_target(target);
-               target->registered = true;
+       scoped_guard(mutex, &target_lock) {
+               if (*(u16 *)target->gen_port_device_handle) {
+                       hmat_update_generic_target(target);
+                       target->registered = true;
+                       return;
+               }
        }
-       mutex_unlock(&target_lock);
 
        /*
         * Skip offline nodes. This can happen when memory
-- 
2.51.1


Reply via email to