Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp131166pxb; Tue, 17 Nov 2020 23:39:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZQxkZWPioCV+s9+FwEuGT7Q3tgVtNdLC9ZeXGeXwtX6pulzmisJCFinfmFNr1zVtAWrPY X-Received: by 2002:a17:906:c41:: with SMTP id t1mr22844015ejf.19.1605685172660; Tue, 17 Nov 2020 23:39:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605685172; cv=none; d=google.com; s=arc-20160816; b=ZHSFjENo87isxkWf9sjkCawKYePpDB1decVmr/oFEZsImL25RAz/mFy+C27mTlO215 ARgTwS2DDG/QbnwOu6vb1C7jjvIW4atpNVJhCneGH4lnZ4xlcclDFLFs4xpbw0sM9gta ifIyZwAglCRkFoHfDMXFYhLWbsiF4nglipvv0Xf/Ize+mfOsoaeSWvtkC03OsemX++2n q4yIERaf2OicUJ/apXlJ/wP3NLwULdqyl2q+rdvP92GERHOyA4Hm/9MBPeuwB5bI7Mma 4hR4YlYnRWIATif/FF9Z0VV1XUnvug7TcFPYlb+LNMxu7qhoeuBf8c4vYSEi2kAS5LBe Pgpw== 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; bh=UdV4Y51MFFOeDm9tt/QM9T7vTpMParsmfIj8wZwAZ7o=; b=s/gvnaPJYTSTBgCq6N62gGrPIcdcOY8oWQQlbukIL2V1xQFZm9spdHp3uo10blzjnt QYUhtpQXTheYTH9EOewhzY1Dm782XCv80YQEj2gBPx3XdAkMtkjuDkSmmlsEpUgLBf8l qjStLb0rBU8ptKtNS0RSucAvw87rjjGT2l92YAvKPdw+7O9ys1cavzuxlT8mg6Tq0epv QCtTQKZJEiSr6PH7kAIqqJ8Qx5Ycv9E3AlPTx3H9nk4li5US9bPIgPUE0jJ6N6sHnJO3 Lwoou+nM7mMUyAIoQ9YSs93dYKocGi76gnG3JUFu41L0hVxD+d4ODjqQn9fLfDtmi/gR f1ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si15820536eje.596.2020.11.17.23.39.10; Tue, 17 Nov 2020 23:39:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726698AbgKRHgl (ORCPT + 99 others); Wed, 18 Nov 2020 02:36:41 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7645 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbgKRHgl (ORCPT ); Wed, 18 Nov 2020 02:36:41 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CbZP56gTbz15MsB; Wed, 18 Nov 2020 15:36:09 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.176.144) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Wed, 18 Nov 2020 15:36:13 +0800 From: Zhen Lei To: Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , "Rafael J . Wysocki" , Len Brown , linux-nvdimm , linux-acpi , linux-kernel CC: Zhen Lei Subject: [PATCH 1/1] ACPI/nfit: avoid accessing uninitialized memory in acpi_nfit_ctl() Date: Wed, 18 Nov 2020 15:35:17 +0800 Message-ID: <20201118073517.1884-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.176.144] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ACPI_ALLOCATE() does not zero the "buf", so when the condition "integer->type != ACPI_TYPE_INTEGER" in int_to_buf() is met, the result is unpredictable in acpi_nfit_ctl(). Signed-off-by: Zhen Lei --- drivers/acpi/nfit/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 442608220b5c..cda7b6c52504 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -282,18 +282,19 @@ static union acpi_object *pkg_to_buf(union acpi_object *pkg) static union acpi_object *int_to_buf(union acpi_object *integer) { - union acpi_object *buf = ACPI_ALLOCATE(sizeof(*buf) + 4); + union acpi_object *buf = NULL; void *dst = NULL; - if (!buf) - goto err; - if (integer->type != ACPI_TYPE_INTEGER) { WARN_ONCE(1, "BIOS bug, unexpected element type: %d\n", integer->type); goto err; } + buf = ACPI_ALLOCATE(sizeof(*buf) + 4); + if (!buf) + goto err; + dst = buf + 1; buf->type = ACPI_TYPE_BUFFER; buf->buffer.length = 4; -- 2.26.0.106.g9fadedd