{"id":806172,"url":"http://patchwork.ozlabs.org/api/patches/806172/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170826225110.7381-5-xypron.glpk@gmx.de/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170826225110.7381-5-xypron.glpk@gmx.de>","list_archive_url":null,"date":"2017-08-26T22:51:05","name":"[U-Boot,04/23] efi_loader: rework efi_locate_handle","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"e84b3730c72c1f8718eb2e334df6be8f783a8722","submitter":{"id":61270,"url":"http://patchwork.ozlabs.org/api/people/61270/?format=json","name":"Heinrich Schuchardt","email":"xypron.glpk@gmx.de"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170826225110.7381-5-xypron.glpk@gmx.de/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/806172/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806172/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xftkR1xBZz9s78\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 27 Aug 2017 08:58:55 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid D0F51C221DF; Sat, 26 Aug 2017 22:53:13 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 1CC02C221B4;\n\tSat, 26 Aug 2017 22:52:26 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 3BD54C22172; Sat, 26 Aug 2017 22:52:11 +0000 (UTC)","from mout.gmx.net (mout.gmx.net [212.227.17.20])\n\tby lists.denx.de (Postfix) with ESMTPS id A4067C221B2\n\tfor <u-boot@lists.denx.de>; Sat, 26 Aug 2017 22:52:08 +0000 (UTC)","from localhost.localdomain ([84.118.154.110]) by mail.gmx.com\n\t(mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id\n\t0M4B71-1dUCs54C71-00rmUf; Sun, 27 Aug 2017 00:51:23 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,\n\tRCVD_IN_MSPIKE_WL autolearn=unavailable\n\tautolearn_force=no version=3.4.0","From":"Heinrich Schuchardt <xypron.glpk@gmx.de>","To":"Alexander Graf <agraf@suse.de>","Date":"Sun, 27 Aug 2017 00:51:05 +0200","Message-Id":"<20170826225110.7381-5-xypron.glpk@gmx.de>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170826225110.7381-1-xypron.glpk@gmx.de>","References":"<20170826225110.7381-1-xypron.glpk@gmx.de>","X-Provags-ID":"V03:K0:QqrLj6G8/G3NeLDshI7lwAFsw9eT1YilZvMjjVNtLIMKb3vP+/B\n\tNML7FvykAim3dypHQiKnokZfRThRZc9JBZk8h1snWImZvkD2S/h/V877/sl/7z6wpGud/+n\n\t7e+rDtDrzw7xxVi0JsauXdjCN787DehVUASOFJrITtJj2K17Z4Qesg0/lpYuymRcSR8uhDs\n\tls1BH2KwzA5kKzM+2oDdw==","X-UI-Out-Filterresults":"notjunk:1; V01:K0:xAxcj7TRe3g=:IDCy6DmmT6SInxAUI8x46y\n\ta8pwFyTFYjiVtr1J05Dzs7xKRJPysTAqZ7BT/nM6pNOyaWPjiKRcSqnaKZ5Hg83kWaNd7iWcH\n\tizfCa8DUDtwh9nT45tooUA93OMtyggSCh5Bnx8MB2HHXc/Dag+D4KTQzVRwxQGAYtJiKfc8UI\n\t8Xv6edcpFIngm+PVNtRYMW5AfgxZLoufXZJQYLEjP26lgVenPsREuJFL6gkWlycm2iqMCfA7x\n\tKorIWUC1vQDqBl9LW5yULcF6M7wEADhpoZ5LjeT5BhiwS/OamN6YbG+CGGnuyH5xEtQSJEBTR\n\triHW94t7bIMVN4AZmaq2CdRGACQSPzoS2eBbDkPaV/Yfx0N4lCJvdT9SPQgk1Cu9tMdbj1Wk9\n\tjgGdod802KcfOiW6QUBEP9MOh+6f0DfIkxDXMvgFGhkEjxniBXoff5jvj8CTYZfERzV9cfwhN\n\tOl78VOYgSKXbcgCK4pbFM2gQa7LFvDJlJDRTSdZFBm0MlzBTjbxZ2OV75z1m2diYLjx+5I1Iy\n\tGn0EEBZhF6TqVpmVDdj4J27WrjYfQCnS0MjlJwp9DC/tKYRRc5iAfSEiOnfWw8vD9voqTAEqK\n\tgjypAh7Vk7vNT7i7ItIiAOktTahGCDrOqCwaoID85APbdQ7h/+mHOMn4xJAvJU5mIjc6Qc81g\n\tlPzsrv4uHnEXu7YKPlWokq9UZQPCXfdWk1WNIhRQvHq96lPI1mHY/fgQaggnCIYKj4V5nq5Hq\n\tXZPXJdb/FnxUTYzJFKj49uE2/ja1InLsGhNWCP2OBAk7Tj57H9TZBk20KuAHICspCQPggizvJ\n\tF9WARKIy9hUi74cgrS1Djc9QiJLOw==","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>, u-boot@lists.denx.de","Subject":"[U-Boot] [PATCH 04/23] efi_loader: rework efi_locate_handle","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Check the parameters in efi_locate_handle.\n\nUse list_for_each_entry instead of list_for_each.\n\nSigned-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n---\n lib/efi_loader/efi_boottime.c | 42 +++++++++++++++++++++++++++++++-----------\n 1 file changed, 31 insertions(+), 11 deletions(-)","diff":"diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\nindex b5538e0769..570a5ea186 100644\n--- a/lib/efi_loader/efi_boottime.c\n+++ b/lib/efi_loader/efi_boottime.c\n@@ -599,6 +599,7 @@ static int efi_search(enum efi_locate_search_type search_type,\n \tcase all_handles:\n \t\treturn 0;\n \tcase by_register_notify:\n+\t\t/* RegisterProtocolNotify is not implemented yet */\n \t\treturn -1;\n \tcase by_protocol:\n \t\tfor (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {\n@@ -617,16 +618,38 @@ static efi_status_t efi_locate_handle(\n \t\t\tefi_guid_t *protocol, void *search_key,\n \t\t\tunsigned long *buffer_size, efi_handle_t *buffer)\n {\n-\tstruct list_head *lhandle;\n+\tstruct efi_object *efiobj;\n \tunsigned long size = 0;\n \n+\t/* Check parameters */\n+\tswitch (search_type) {\n+\tcase all_handles:\n+\t\tbreak;\n+\tcase by_register_notify:\n+\t\tif (!search_key)\n+\t\t\treturn EFI_INVALID_PARAMETER;\n+\t\t/* RegisterProtocolNotify is not implemented yet */\n+\t\treturn EFI_UNSUPPORTED;\n+\tcase by_protocol:\n+\t\tif (!protocol)\n+\t\t\treturn EFI_INVALID_PARAMETER;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn EFI_INVALID_PARAMETER;\n+\t}\n+\n+\t/*\n+\t * efi_locate_handle_buffer uses this function for\n+\t * the calculation of the necessary buffer size.\n+\t * So do not require a buffer for buffersize == 0.\n+\t */\n+\tif (!buffer_size || (*buffer_size && !buffer))\n+\t\treturn EFI_INVALID_PARAMETER;\n+\n \t/* Count how much space we need */\n-\tlist_for_each(lhandle, &efi_obj_list) {\n-\t\tstruct efi_object *efiobj;\n-\t\tefiobj = list_entry(lhandle, struct efi_object, link);\n-\t\tif (!efi_search(search_type, protocol, search_key, efiobj)) {\n+\tlist_for_each_entry(efiobj, &efi_obj_list, link) {\n+\t\tif (!efi_search(search_type, protocol, search_key, efiobj))\n \t\t\tsize += sizeof(void*);\n-\t\t}\n \t}\n \n \tif (*buffer_size < size) {\n@@ -639,12 +662,9 @@ static efi_status_t efi_locate_handle(\n \t\treturn EFI_NOT_FOUND;\n \n \t/* Then fill the array */\n-\tlist_for_each(lhandle, &efi_obj_list) {\n-\t\tstruct efi_object *efiobj;\n-\t\tefiobj = list_entry(lhandle, struct efi_object, link);\n-\t\tif (!efi_search(search_type, protocol, search_key, efiobj)) {\n+\tlist_for_each_entry(efiobj, &efi_obj_list, link) {\n+\t\tif (!efi_search(search_type, protocol, search_key, efiobj))\n \t\t\t*(buffer++) = efiobj->handle;\n-\t\t}\n \t}\n \n \treturn EFI_SUCCESS;\n","prefixes":["U-Boot","04/23"]}