Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2803625rwn; Fri, 9 Sep 2022 22:14:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR7n8FVgu1PG4aS9zdoYYSnbmsR0qMxei1VexCbULLzA6PEtvX7dkyaXAvAUzLRQyFyQeqoC X-Received: by 2002:a17:902:e750:b0:176:b0fb:9683 with SMTP id p16-20020a170902e75000b00176b0fb9683mr16991897plf.71.1662786875671; Fri, 09 Sep 2022 22:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662786875; cv=none; d=google.com; s=arc-20160816; b=m4Fgm1svMa6TvVPbpUMbSNdd0nkfh9udSByvg7rjJCWBOpbSWmNRvZTeE8r6FdjewM UKqMhbSPqJ9ni0ATYlNFWDxgV5jJwuSCODyp8vJeG9k3kOQIVlWsBCdsXxlJTgLqJrKj +ZuDUDGoEf6+96N0MSzRgwTUynIS6jyqkZGZY/6iPCoaOdtnog+n5RSFQ1ipEJJzW2vJ PdZ0SrzWj8SGxE3VnuCIY+Y4zsR7qNJNHlJrfi1zEFPsfHDA0rc7+rwJbVEFTnIbU8Er GruxZxrcybQ4uPq3t6TrevaeNm4cYUI1gamGFGsMsB3xm9+Wym/mPSaQwXqIAoBADl4H p3Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=gae5gOF+F5G7+t7MdveDQyrPj9gKE6c+D4R+s5c3W8o=; b=kI72zU+wtHE8dZYS5cezK4SATE1Wql0u7oqDb0rd9i7yZ7hx39Wx/RzlLSBs1v1spT A+t9qblCaxvnwfK6Wk8UvtbSaV877JSpP/HwyA0j8NzusAXd0eFDE83hbNCTSka9xoQe PUVgqFwBRKI5tP7pYvB9pVzLGG9zPKqC9s2m8wbjH2OYreBjMvrCNt/fpKuyNdM+2fbP Gh93fpVFvQAqsLQKCdNNR9jPuLETf0TLvOXbaNslhVTqqP9ntsPdJDKER5FRoQ/oS3Pl 7lLhVUPO4jUz3v7UvmYzOZLbQFK0UTH1JwckoPtqLvXMb3NB4ch4HrzOdNJnbkG4TABK yqFw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a170902e5c500b001746da9a657si2829213plf.56.2022.09.09.22.14.23; Fri, 09 Sep 2022 22:14:35 -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 S229702AbiIJE46 (ORCPT + 99 others); Sat, 10 Sep 2022 00:56:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbiIJE44 (ORCPT ); Sat, 10 Sep 2022 00:56:56 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2963CB9402 for ; Fri, 9 Sep 2022 21:56:54 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id WsXsooWDfez1rWsXsoPi6u; Sat, 10 Sep 2022 06:56:52 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Sep 2022 06:56:52 +0200 X-ME-IP: 90.11.190.129 Message-ID: <04d65bd7-a6b2-bb14-fd69-632542ae9e86@wanadoo.fr> Date: Sat, 10 Sep 2022 06:56:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH V2] efi: efibc: Guard against allocation failure Content-Language: en-US To: "Guilherme G. Piccoli" , linux-efi@vger.kernel.org Cc: ardb@kernel.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, matt@codeblueprint.co.uk, mjg59@srcf.ucam.org References: <20220909194214.186731-1-gpiccoli@igalia.com> From: Christophe JAILLET In-Reply-To: <20220909194214.186731-1-gpiccoli@igalia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Le 09/09/2022 à 21:42, Guilherme G. Piccoli a écrit : > There is a single kmalloc in this driver, and it's not currently > guarded against allocation failure. Do it here by just bailing-out > the reboot handler, in case this tentative allocation fails. > > Fixes: 416581e48679 ("efi: efibc: avoid efivar API for setting variables") > Signed-off-by: Guilherme G. Piccoli > --- > > V2: > * Rebased against 6.0-rc4; > * Dropped from the original series [0]. > > [0] https://lore.kernel.org/linux-efi/20220729194532.228403-1-gpiccoli@igalia.com/ > > > drivers/firmware/efi/efibc.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c > index 8ced7af8e56d..4f9fb086eab7 100644 > --- a/drivers/firmware/efi/efibc.c > +++ b/drivers/firmware/efi/efibc.c > @@ -48,6 +48,9 @@ static int efibc_reboot_notifier_call(struct notifier_block *notifier, > return NOTIFY_DONE; > > wdata = kmalloc(MAX_DATA_LEN * sizeof(efi_char16_t), GFP_KERNEL); Hi, even if mostly useless in this case, kmalloc_array()? Or certainly maybe even better, kstrndup()? CJ > + if (!wdata) > + return NOTIFY_DONE; > + > for (l = 0; l < MAX_DATA_LEN - 1 && str[l] != '\0'; l++) > wdata[l] = str[l]; > wdata[l] = L'\0';