From patchwork Sun Oct 16 20:03:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 3149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1145739wrs; Sun, 16 Oct 2022 13:37:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7IMQ6ZJP28TEESSdfkVRrpYUTXC9dGFXZ3xc3wxEGH+8p/r/nk+fjVGbSXKWtU/WbXL1xw X-Received: by 2002:a17:906:8a66:b0:78b:da52:b752 with SMTP id hy6-20020a1709068a6600b0078bda52b752mr6176332ejc.365.1665952627767; Sun, 16 Oct 2022 13:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665952627; cv=none; d=google.com; s=arc-20160816; b=DefE+I4A8z8yeBDI1JDWsJzUo+bppJ9AOrWGLWC3/3hujTCZ5cweLMrVQmF/jWrLBJ 426s7u3q6Jh8S9oP1t6Sj5FumLvglAe+zBWD0gnqx2shwoDYCYwAMpeivX2PV/nbDcVX 9Rozr9bYnfhtb1hMidYeqUSLREkt+eyoCJqGsG0SeFPQoG5a5X9qEOHMQFammrE1iGyT GUYvLj6cWyVMYJBv3BzUeMv8M6jQE7dyx41wz83G+o2e5uiv4uuNfvCG/kcl4ONlZJMA BEkAaL7aDKBcOGfqWxjF93xMem5EV/8fNxXre7ZMiyOi17PMuWDvlcmMfQ6aac6KvVrI z8bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=z+t9BNHjMu+eDDWW8Bpn+QbNYtzAAIAvUkktEfs8bi8=; b=g6SlG7s1wFVmk3DaK7LwtHT/Pj3RgmDYF8Zdrc7L6nEMeG4DjarJFFMHk+C3tcz4/n sXoKrArxwlL2KPGUwaZzyhofKM03HA3ZBfTdFgbSSDSoVtbbEknHEXEd8u1k08scoTHY wxXavm+mrwV6txUyyNzbg8X5fpxRK01MjP+aHlEE+0Di7jRMsmD63yCkoblmyfqTghGp fWG7gg1+Rs3J5oqOyzqRECPRTVCZMtoLzJMrlo1I3qqnPUX9RNdUsAqUWR021gIuCJ4Z ONP3i5ZALNa9VwXgkVVzy6bYlyF61srCm5FOgx7KW8snJdncA0IhwzHNEbO9+lajTfPs Ti7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a1709064fc700b00782ff2649a7si8386745ejw.346.2022.10.16.13.36.43; Sun, 16 Oct 2022 13:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbiJPUPl (ORCPT + 99 others); Sun, 16 Oct 2022 16:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiJPUPj (ORCPT ); Sun, 16 Oct 2022 16:15:39 -0400 X-Greylist: delayed 682 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 16 Oct 2022 13:15:36 PDT Received: from h5.fbrelay.privateemail.com (h5.fbrelay.privateemail.com [162.0.218.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C54D92656D for ; Sun, 16 Oct 2022 13:15:36 -0700 (PDT) Received: from MTA-13-3.privateemail.com (mta-13-1.privateemail.com [198.54.122.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by h5.fbrelay.privateemail.com (Postfix) with ESMTPS id D8863606D1 for ; Sun, 16 Oct 2022 20:04:11 +0000 (UTC) Received: from mta-13.privateemail.com (localhost [127.0.0.1]) by mta-13.privateemail.com (Postfix) with ESMTP id 33F5018000AB; Sun, 16 Oct 2022 16:04:10 -0400 (EDT) Received: from hal-station.. (bras-base-toroon4321w-grc-73-76-67-77-249.dsl.bell.ca [76.67.77.249]) by mta-13.privateemail.com (Postfix) with ESMTPA id 3754918000A7; Sun, 16 Oct 2022 16:04:02 -0400 (EDT) From: Hamza Mahfooz To: linux-kernel@vger.kernel.org Cc: Hamza Mahfooz , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org Subject: [PATCH] drm/framebuffer: break out of loop, if the requested element is found Date: Sun, 16 Oct 2022 16:03:23 -0400 Message-Id: <20221016200324.17930-1-someguy@effective-light.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746877942803947498?= X-GMAIL-MSGID: =?utf-8?q?1746877942803947498?= We can stop searching through the linked-list after we have found the element we are looking for. So, break out of list_for_each_entry() after we have found the element we are looking for in drm_mode_rmfb(). Signed-off-by: Hamza Mahfooz --- drivers/gpu/drm/drm_framebuffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 2dd97473ca10..557177a4c5be 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -441,8 +441,11 @@ int drm_mode_rmfb(struct drm_device *dev, u32 fb_id, mutex_lock(&file_priv->fbs_lock); list_for_each_entry(fbl, &file_priv->fbs, filp_head) - if (fb == fbl) + if (fb == fbl) { found = 1; + break; + } + if (!found) { mutex_unlock(&file_priv->fbs_lock); goto fail_unref;