Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2416893rwn; Fri, 9 Sep 2022 13:26:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR6hBJahhVHPs1xsv9KDnAPBLAJA2UHekzVuuLTHDII2b38hAqMCz/QK5ukw7xTzLmpOCb9G X-Received: by 2002:a05:6402:2786:b0:44f:2d99:93d1 with SMTP id b6-20020a056402278600b0044f2d9993d1mr9921036ede.324.1662755206857; Fri, 09 Sep 2022 13:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662755206; cv=none; d=google.com; s=arc-20160816; b=cEElVoiD7PPMT5kNZwIsaZJ3KdH4ml9FrWsQ8UBrDJGZhFoUOx+781jYh6a/BPuf6r Ri04GTrNt+oaSe/rVl7avG9ERBORlFW7IyIA7v0wx4E2xMBKad6tWgRRO1gze4rm3NiI HKdrBRN3X3I+4b8oRQrOkKRxQ3PF4701R2aLFzOHwZ39f24Afvb85ucMYr0u8f/4DhPN OI4ueIxDurNuIHVjvyXM6myGcxBtbNpOTKowNWhNkig8peGhK2mnhLEFPsgFa5shVEN8 P+/lTz9AWiznL4l2ofbereZow9YhzNeHKw5zGx+O8oI5lsrHFJgonoLdrDY2lxoKziQF rG2w== 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:dkim-signature; bh=/q9eNcU3uzrC4vnpWsAF5H9wAjfFopX07fmzyDgI15M=; b=jLdGQVJkY3d9hpVRPY+JNutPsdtS5QFxXAaqMRpI+QCBOCQ8DVvZiO+v6lWoztZBhD Ifh6HRPh8D9oeHx1QdQ9AL4KGSWxK/PNW0rJ8E9fGuU4q2JUaqwKNPakEvRmmiwkTmGm bJ2my3KyLQ1xJ6Yme4pr7UUYub0A59f0FQ3yW+ijobCcV0co9ZfZZjEoTLHYqO05vdaA SchK+HvfOEx5SYqKbo7SMx2h/kPvgEJfKPXNYzsmBHC+QuFPHF+f3c1lr83F3XPNCE2g UO+Na8BWwXrdze1pE8OBh85qyv1AfggYSmpDvKpFTZTRLtpuf4G7t4FkM9GEiYoW8ixt AqGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=AtvsIuqK; 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 m7-20020a50d7c7000000b0044e6a188fa8si1151282edj.184.2022.09.09.13.26.21; Fri, 09 Sep 2022 13:26:46 -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=AtvsIuqK; 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 S231874AbiIITqt (ORCPT + 99 others); Fri, 9 Sep 2022 15:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231932AbiIITqO (ORCPT ); Fri, 9 Sep 2022 15:46:14 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348B236869; Fri, 9 Sep 2022 12:42:48 -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: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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/q9eNcU3uzrC4vnpWsAF5H9wAjfFopX07fmzyDgI15M=; b=AtvsIuqKCKXtdg78Gc+1WUzE8b dPJVkIa/LVmXo1MsStXD32O8hF1TUOKb4Yi02aOtlLfr1zKxqzYiPNSF+zSoCh7KFEU8g8GhdtB2W tj2IXFa5GraXvFjaGW07lEK/V6SefMSj2N0b3Gokcnyjs/VL6zjPZ4bdeOVn2A1zscyt2jvpXt87i oStBDQQdoikF/txOT7Ug1inDhdM5b0kbfddgo8RwJBAotyWB9vhWkcK7iOJqu7KxmbJIc9QUrdoyd hExDDtRkWd9XbJlSJgkL6rnCdO19Xe36Re+VeV6+IQI3Av9AZ/TToPYKLZSyxgJ/+eX2PLoYH+0Vy E3rPHm7g==; Received: from [177.215.76.177] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1oWjtX-00E5na-3x; Fri, 09 Sep 2022 21:42:31 +0200 From: "Guilherme G. Piccoli" To: 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, "Guilherme G. Piccoli" Subject: [PATCH V2] efi: efibc: Guard against allocation failure Date: Fri, 9 Sep 2022 16:42:14 -0300 Message-Id: <20220909194214.186731-1-gpiccoli@igalia.com> X-Mailer: git-send-email 2.37.2 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, 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 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); + 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'; -- 2.37.2