Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1243317pxb; Wed, 10 Feb 2021 03:54:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+ywOa0ekeK6GzjR8Z6if23m94zdPIekX1BG3AWZHOe4x10GfMWhbiGCgOAF4J4GE8I6Cv X-Received: by 2002:a17:906:dfce:: with SMTP id jt14mr2579571ejc.345.1612958058332; Wed, 10 Feb 2021 03:54:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612958058; cv=none; d=google.com; s=arc-20160816; b=kbVs+WXz6q06NzasJOHYBGg3MJRJRpHSMjKzzJndaSX+pWbFV/KgxAPLVibGPO9ieT pHGOR4lyzVVgBz2rYH7RNtnZOsxrwwhLJ6ubNWno/FyfX6i71alZEq8HZsvm5Kt5Qx7d F5wLGJaIlGR6gaov646l5Y6jEAOUI70Vl05SwnXmPp5mSmHi2bp28MNh4SC3hbrLb93p QIjq2jrz5siR0TWQA/gTg+jXmfEV00xv5GJ33ZxPH4YZDMkShGBUDlvzJ0v3mtMYt82a VkYMgS3kdtV3uHg8/I+gplYO4zXzaUWsdbUjb6tr9N1FlOzFC5aLk8xhpelBSK+3fE6K eFag== 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 :ironport-sdr:ironport-sdr; bh=4JwXr3AChG7g//OLmdjDm1h4S8NjF+n7wjae0c7OpGk=; b=NIvW9/hA3jOPtzmxwymTssk0pghCxyne+lpNS8sS76+tjIdP9bPNnmN5dAYQnYGTaj j6crvKw3EAJpRJRSADKOACIZ6RjF9F2MhOXIn1P3Nehfo53Kt8SYpTTh6QZv0KsLAl6j EA+V8ReUOCvL+Boxf/XHyALyJ040N77d9dkrkG0GQPkrhBSlhRMwOUy0SZBx6YYOcHT4 1r89Xb2oM7uP/NAtLU//VOzy4+eimNafz/Yqs2kO2wvnB3djrAWNbQEMMXfnyCynlNuO 9khprnHU/yC7UN5EFp5hF5FnnriWEvps/OEioHT/a/AZONCMLlQh7wyzRxtl7ZSRauYE UluA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si1118989ejj.506.2021.02.10.03.53.54; Wed, 10 Feb 2021 03:54:18 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbhBJLuf (ORCPT + 99 others); Wed, 10 Feb 2021 06:50:35 -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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.30.0