From patchwork Wed Feb 10 11:43:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 380284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48858C433E9 for ; Wed, 10 Feb 2021 11:48:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E70C264E40 for ; Wed, 10 Feb 2021 11:48:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231425AbhBJLsB (ORCPT ); Wed, 10 Feb 2021 06:48:01 -0500 Received: from mga14.intel.com ([192.55.52.115]:35842 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbhBJLpq (ORCPT ); Wed, 10 Feb 2021 06:45:46 -0500 IronPort-SDR: mRqAMFhw9wnHudgI/f8KPpsmjWQu7XLKBJLOJq8TYWP4AHASMwhJjKJ2rUOFyTotVdjva1An6S 194UYHSW1/Iw== X-IronPort-AV: E=McAfee;i="6000,8403,9890"; a="181283663" X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="181283663" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2021 03:43:36 -0800 IronPort-SDR: bbPMqO0O8CLgv1cqYS7a6OjiNs3DZBAvu1C6NRzyeJ3H7KDbr1mSHDjnxNc8fwpP6n0maCn2ei 1xFbCEilQdfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="436645535" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 10 Feb 2021 03:43:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 683AA4BE; Wed, 10 Feb 2021 13:43:32 +0200 (EET) From: Andy Shevchenko To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , Andy Shevchenko Subject: [PATCH v1 6/7] ACPI: property: Allow to validate a single value Date: Wed, 10 Feb 2021 13:43:19 +0200 Message-Id: <20210210114320.3478-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210114320.3478-1-andriy.shevchenko@linux.intel.com> References: <20210210114320.3478-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org acpi_data_prop_read_single() doesn't accept a NULL parameter for the value. Let's modify it to accept NULL pointer in order to validate the single value. This will be needed for the further changes. Signed-off-by: Andy Shevchenko --- drivers/acpi/property.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index f2386ef32ff1..236316ee0e25 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -787,9 +787,6 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, const union acpi_object *obj; int ret = 0; - if (!val) - return -EINVAL; - if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj); else if (proptype == DEV_PROP_STRING) @@ -801,23 +798,28 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, case DEV_PROP_U8: if (obj->integer.value > U8_MAX) return -EOVERFLOW; - *(u8 *)val = obj->integer.value; + if (val) + *(u8 *)val = obj->integer.value; break; case DEV_PROP_U16: if (obj->integer.value > U16_MAX) return -EOVERFLOW; - *(u16 *)val = obj->integer.value; + if (val) + *(u16 *)val = obj->integer.value; break; case DEV_PROP_U32: if (obj->integer.value > U32_MAX) return -EOVERFLOW; - *(u32 *)val = obj->integer.value; + if (val) + *(u32 *)val = obj->integer.value; break; case DEV_PROP_U64: - *(u64 *)val = obj->integer.value; + if (val) + *(u64 *)val = obj->integer.value; break; case DEV_PROP_STRING: - *(char **)val = obj->string.pointer; + if (val) + *(char **)val = obj->string.pointer; return 1; default: return -EINVAL;