Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp493148imn; Fri, 29 Jul 2022 13:29:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tp92NwPdnrlj9AfoWMR6JMw3PPc8VtnueDjAhILDaf3xT+Sr0P1kMgG/O3wNciG46ZRkzd X-Received: by 2002:a05:6a00:248b:b0:52b:f07b:796c with SMTP id c11-20020a056a00248b00b0052bf07b796cmr5013044pfv.47.1659126593575; Fri, 29 Jul 2022 13:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659126593; cv=none; d=google.com; s=arc-20160816; b=JAJ8UgrI1PB4e9/VzmU3Ct34/LlEkSaoYqVVSwJr/1draWHf7JQ9EoaaB1uFwkk6Un hJCMI3AnPotNqCuVnlu9+9/LpTtMuKrSOScU/h6ElWYPmAQ8/WbeO+Kq5j9rwaWy0a92 Hvd6yN7zTlg6ndsizVYast65/xtWym4CuBx7DBBXQVFm1WCXl2LfyKLOPVsBkEou2m1M +4814tuQ1QBzJp87/SnRkhTdku84OU5y5iqEPrAhPAZ/eCex0fw6lKfI9Y3lLqGd/yGl gSwXRx3314AjoxTGCAV7lE/H6IY9f9hkpfI+pqshbHvyl2SHFzsast0WxQy2bbNc+AE/ cMCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gSESq/zVK6WSQ3xcbCVSVTd/pkQVDwB+RHkhs8Ulxac=; b=GjIoWWjXWsL2wruuKM5c6MQDkB+lBxb9Pff0pXLyxHNHtRnnBYCxX/S67Av9ZHWSRW grOTgX+29SsShT97mXexAwhTeOPT+l/qAuHA1BYQ4YkOtj3RBwMV0m+08nWo7PYsbx8E VKQFNlk6p46P2ZCZn+eQjT/x/N4u1r2DC1Lf3Nk3Wcv1saeIB76PrmbOji9baYjdF+LF ahp3tzjcU0ZT21mdOPhwimIvYcy45oe65dEswWtNBXcaNwmcfZK4dx4ZBllXnfOQkRcG oO0YXGKCz9RxArvSuxm1DpMnTld7dyTudiYnfMk7tcQrOXjJMYNqBFgWLof9uMLSemH2 C6Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=gNAcLB5d; 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 nh24-20020a17090b365800b001efa5c358f1si4582005pjb.26.2022.07.29.13.29.37; Fri, 29 Jul 2022 13:29:53 -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; dkim=fail header.i=@igalia.com header.s=20170329 header.b=gNAcLB5d; 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 S238623AbiG2Tr6 (ORCPT + 99 others); Fri, 29 Jul 2022 15:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbiG2Tr4 (ORCPT ); Fri, 29 Jul 2022 15:47:56 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 063E267586; Fri, 29 Jul 2022 12:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=gSESq/zVK6WSQ3xcbCVSVTd/pkQVDwB+RHkhs8Ulxac=; b=gNAcLB5d5hgvc2ZzPkGFjiZVW7 0wze4qmrg6EMBcxInS7qXkVTjCCvh+IdzCRriHcL10eYbixF8Fqa7w/I9C07CmmJIMPxBDt7O5VHJ 75RVNHJd//nqO9xg5YO7UFgFbQE0GmGCv8A+gECGgvVeTpeGw3BSLBiW36dO/wStv3fsz7pxq1zAF wZU9FHxDfm8wx9NyiextdgXREkwhSoz4tRJ+r26MOhdEh9xz1DgVzY/qSM/+4kSZ9KKRdvsRn3Poo OPJHBOf05KYUFR+QRMLKXfLtzM7jqKM7B332IBErDQ21kEZKCnzqyZlETL3ipEjedfzqbpOsKuU3L M+ikN8QQ==; Received: from [177.83.209.223] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1oHVxf-00BMHE-D5; Fri, 29 Jul 2022 21:47:54 +0200 From: "Guilherme G. Piccoli" To: ardb@kernel.org, linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, anton@enomsg.org, ccross@android.com, keescook@chromium.org, matt@codeblueprint.co.uk, mjg59@srcf.ucam.org, tony.luck@intel.com, "Guilherme G. Piccoli" Subject: [PATCH v2 2/3] efi: efibc: Guard against allocation failure Date: Fri, 29 Jul 2022 16:45:31 -0300 Message-Id: <20220729194532.228403-3-gpiccoli@igalia.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220729194532.228403-1-gpiccoli@igalia.com> References: <20220729194532.228403-1-gpiccoli@igalia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,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 There is a single kmalloc in this driver, and it's not currently guarded against allocation failure. Do it here by just letting the reboot handler to proceed, in case this tentative allocation fails. Fixes: 416581e48679 ("efi: efibc: avoid efivar API for setting variables") Signed-off-by: Guilherme G. Piccoli --- Notice the sha-1 hash of the efibc patch we're fixing is from efi/next, might change in upstream once such patch is merged. Feel free to remove the fixes tag if it makes sense, no issues from me =) drivers/firmware/efi/efibc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c index 7e3bf60d24e0..9a8d914f91a6 100644 --- a/drivers/firmware/efi/efibc.c +++ b/drivers/firmware/efi/efibc.c @@ -48,6 +48,8 @@ static int efibc_reboot_notifier_call(struct notifier_block *notifier, return NOTIFY_DONE; wdata = kmalloc(MAX_DATA_LEN * sizeof(efi_char16_t), GFP_KERNEL); + if (!wdata) + return NOTIFY_DONE; len = efi_str8_to_str16(wdata, str, MAX_DATA_LEN - 1); -- 2.37.1