[{"id":1760938,"web_url":"http://patchwork.ozlabs.org/comment/1760938/","msgid":"<CAPnjgZ3RW8jvV1yVuRfLgNmwo5XD4TRLGh2SYYLE7d+b1Gx8LA@mail.gmail.com>","list_archive_url":null,"date":"2017-08-31T12:51:20","subject":"Re: [U-Boot] [PATCH 04/23] efi_loader: rework efi_locate_handle","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/","name":"Simon Glass","email":"sjg@chromium.org"},"content":"Hi Heinrich,\n\nOn 27 August 2017 at 06:51, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:\n> Check the parameters in efi_locate_handle.\n>\n> Use list_for_each_entry instead of list_for_each.\n>\n> Signed-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(-)\n>\n\nReviewed-by: Simon Glass <sjg@chromium.org>\n\nnits below\n\n> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\n> index 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>         case all_handles:\n>                 return 0;\n>         case by_register_notify:\n> +               /* RegisterProtocolNotify is not implemented yet */\n>                 return -1;\n>         case by_protocol:\n>                 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {\n> @@ -617,16 +618,38 @@ static efi_status_t efi_locate_handle(\n>                         efi_guid_t *protocol, void *search_key,\n>                         unsigned long *buffer_size, efi_handle_t *buffer)\n\nfunction needs a comment\n\n>  {\n> -       struct list_head *lhandle;\n> +       struct efi_object *efiobj;\n>         unsigned long size = 0;\n>\n> +       /* Check parameters */\n> +       switch (search_type) {\n> +       case all_handles:\n> +               break;\n> +       case by_register_notify:\n> +               if (!search_key)\n> +                       return EFI_INVALID_PARAMETER;\n> +               /* RegisterProtocolNotify is not implemented yet */\n> +               return EFI_UNSUPPORTED;\n> +       case by_protocol:\n> +               if (!protocol)\n> +                       return EFI_INVALID_PARAMETER;\n> +               break;\n> +       default:\n> +               return EFI_INVALID_PARAMETER;\n> +       }\n> +\n> +       /*\n> +        * efi_locate_handle_buffer uses this function for\n> +        * the calculation of the necessary buffer size.\n> +        * So do not require a buffer for buffersize == 0.\n> +        */\n> +       if (!buffer_size || (*buffer_size && !buffer))\n> +               return EFI_INVALID_PARAMETER;\n> +\n>         /* Count how much space we need */\n> -       list_for_each(lhandle, &efi_obj_list) {\n> -               struct efi_object *efiobj;\n> -               efiobj = list_entry(lhandle, struct efi_object, link);\n> -               if (!efi_search(search_type, protocol, search_key, efiobj)) {\n> +       list_for_each_entry(efiobj, &efi_obj_list, link) {\n> +               if (!efi_search(search_type, protocol, search_key, efiobj))\n>                         size += sizeof(void*);\n> -               }\n>         }\n>\n>         if (*buffer_size < size) {\n> @@ -639,12 +662,9 @@ static efi_status_t efi_locate_handle(\n>                 return EFI_NOT_FOUND;\n>\n>         /* Then fill the array */\n> -       list_for_each(lhandle, &efi_obj_list) {\n> -               struct efi_object *efiobj;\n> -               efiobj = list_entry(lhandle, struct efi_object, link);\n> -               if (!efi_search(search_type, protocol, search_key, efiobj)) {\n> +       list_for_each_entry(efiobj, &efi_obj_list, link) {\n> +               if (!efi_search(search_type, protocol, search_key, efiobj))\n>                         *(buffer++) = efiobj->handle;\n\n*buffer++\n\n> -               }\n>         }\n>\n>         return EFI_SUCCESS;\n> --\n> 2.14.1\n>\n\nRegards,\nSimon","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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"NPPiMDkz\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"ivmcdj+C\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjj464Gymz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 22:53:58 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 3D33BC21E1D; Thu, 31 Aug 2017 12:52:06 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id AE054C21D93;\n\tThu, 31 Aug 2017 12:51:55 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid D368DC21C62; Thu, 31 Aug 2017 12:51:46 +0000 (UTC)","from mail-qt0-f174.google.com (mail-qt0-f174.google.com\n\t[209.85.216.174])\n\tby lists.denx.de (Postfix) with ESMTPS id CAA38C21E0C\n\tfor <u-boot@lists.denx.de>; Thu, 31 Aug 2017 12:51:42 +0000 (UTC)","by mail-qt0-f174.google.com with SMTP id e2so2394021qta.0\n\tfor <u-boot@lists.denx.de>; Thu, 31 Aug 2017 05:51:42 -0700 (PDT)","by 10.200.28.106 with HTTP; Thu, 31 Aug 2017 05:51:20 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=eTNqM5WbMoFRk3rqXNO2tkIFzIEaBbpOpmD+SsJx86E=;\n\tb=NPPiMDkzPDMCAoGdjLHMniqvSGcGI7dCOJlBf157SsQyHKipWxCm28XWeO1Zhe23BF\n\t744rDzYLYmfDVPesgz0FcIyNoUPBNT4lC8zO6vSbrgQyGEn2zPQa88LUqzeXptZE8PvX\n\tAcTBlIK6nafsQmeiR6gRTtBOkdHtF0vbMiGbnEl7NLScnZDTA5svLFlTo2YSewCObqaq\n\t4PEe0snlkz8jXTKVLdS09bWRYSLJbQJguvuWTrA+uDT0KwkJywjPKYGNKYWGRKlIQfQ7\n\tTmfPv5OOK1wfCCY79twugGpPR/catbta1MWRxOsB1YX91e4FhvijpYRB3X34CxBmWi1d\n\thN8A==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=eTNqM5WbMoFRk3rqXNO2tkIFzIEaBbpOpmD+SsJx86E=;\n\tb=ivmcdj+CUd8clu9PTYIPacIkypJmL3QLXMFMWwGJDAmBANyOmmC+tNqVHkHI5ZXeBj\n\tatA5lkepAb7uiAnPXbhCwmfwix5GUUufxiWh0NtPKdn84M+EtnYAznuYR5BGSvtaVvQP\n\tBOv3EtztQPJiBHjpQUeXtuRJGauU4Uhui5ixM="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc;\n\tbh=eTNqM5WbMoFRk3rqXNO2tkIFzIEaBbpOpmD+SsJx86E=;\n\tb=jCJgKbzaZi6nLGbRywc77MEYUTO3yCXRAJGT60zTZt5JRpd8l47Aa1jF740KK19fgf\n\t9pSRSwEz4+iPRVyrHsepSxWJBTGJuJCkrjOng7cCFRVyu4DjdO9Afj86CFHUpoKrkMxY\n\tlR/9kWMJNGV8L/xd3WGd8sosO3Rf1GWrEPhrJCpCMk8UbVqvUG7m3PBXDyJf+hK0Lky2\n\t6S0CqSlI6UbB8pDV+5ehXSA9AeqkSVBr+n00g98nhtAIMz2ICawP05JcCByLcFaGr5Am\n\tIizP6za2DuidxSGT/BUYq48q6PhFzzh9iFwYf5HjvVH8KZQDkKH3pUv+703cn323CHSs\n\tHDDg==","X-Gm-Message-State":"AHYfb5jqL7ekZX8RpAh9IXLpDZrSqq6DmGRz3rDNZRsPfayyKcx6wHty\n\tY1qUAfBaL4e3DZGwIZjORUXz6GPDeWPe","X-Google-Smtp-Source":"ADKCNb6mgrZ5OIn6uowxO9D0e2Zp0lOQmdkL+BS6ekCpIfh1T0Z4ATct8z8Bhx24mWJM/Tiy4ABCdaAwucZlpR4mvik=","X-Received":"by 10.200.24.173 with SMTP id s42mr6660636qtj.38.1504183901570; \n\tThu, 31 Aug 2017 05:51:41 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170826225110.7381-5-xypron.glpk@gmx.de>","References":"<20170826225110.7381-1-xypron.glpk@gmx.de>\n\t<20170826225110.7381-5-xypron.glpk@gmx.de>","From":"Simon Glass <sjg@chromium.org>","Date":"Thu, 31 Aug 2017 20:51:20 +0800","X-Google-Sender-Auth":"hK9XftPfqPnXrDz9-I5kVT1NTNY","Message-ID":"<CAPnjgZ3RW8jvV1yVuRfLgNmwo5XD4TRLGh2SYYLE7d+b1Gx8LA@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [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>","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>"}}]