Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7837931imu; Tue, 22 Jan 2019 12:30:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5yXwTaOj+cwHuyPZn5goGJu/5VoZMLw4KL6SHvdbD86oxirU4cG+Xg3e9HI+g2mijLzR7R X-Received: by 2002:a17:902:28aa:: with SMTP id f39mr35967518plb.297.1548189059000; Tue, 22 Jan 2019 12:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548189058; cv=none; d=google.com; s=arc-20160816; b=d4OzZ2NMtiZ/FDAynf9GBo/CA16xPRPVinV9SZsj9RLnR+w+cly+gBlyrzrE66uCaR OeaNi5eIwP8/9c4jNtsjrpVA/EvCVhaICFqSi0oBqUAywD5+Gm33KuYdp/B4L4wvwa1K 5vBylTUX7Nh+DJga6p7vTKnxK4otmHaMpVqZkxvwlAj0acOOccvrCJh+sQWoPCrLDSvZ KDYnVIodhq/fwKCJycQHmC9yvM9pSMp67Gn7KCAxwccZH0jskY+NnxnC8f+6Q4ET5odB ZTDiniQLTpBWkZTUKO7stCkYT8dJoh9Z3vY5qq8BvAVQYxCuPEMbIn11X/Y5SEvFCJM1 hryg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=/vM8EZ36y1Ke/Tf6Jv73AXQnvdXnsEIn+q+G8roKCQ4=; b=wrQreoVarnNLjffJa9lXsr9advzsIbHmQwj+obDcEzRAojkDEam7SoslLM8qNsObra THNsGaVjhXsqU4EToJ1W+GIRqyTIDLpr44H7yE3wz78PbEvWvUXElJ/pbgrET2NVNb/u pvFMbJu/vHXJlPGEOyEuEt0jd2pr/kYmopP8NMMcYTTsFddaIwPEdNNeii9WAMUmARtc ZmWrA9MiX8OthItwXNJ2g5Azcn0BuwUrHzo7vwKjiA48nZoR7+PWz62ud3TS+N4v2QjX pTW+P4kYYOOQ9xNMtKQddyf/I4dAtUHAHh2O8PJeGn64d+39x5UpUPTHWCYRuN3yP4AP 448A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mok.nu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si16447480plc.332.2019.01.22.12.30.43; Tue, 22 Jan 2019 12:30:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mok.nu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbfAVU3P (ORCPT + 99 others); Tue, 22 Jan 2019 15:29:15 -0500 Received: from proxy05.fsdata.se ([89.221.252.250]:56070 "EHLO mail-gw01.fsdata.se" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725862AbfAVU3L (ORCPT ); Tue, 22 Jan 2019 15:29:11 -0500 Received: from localhost (94.234.43.8) by DAG01.HMC.local (192.168.46.11) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Tue, 22 Jan 2019 21:29:05 +0100 Date: Tue, 22 Jan 2019 21:28:59 +0100 From: Mattias Jacobsson <2pi@mok.nu> To: , CC: , , <2pi@mok.nu> Subject: Re: [PATCH 1/3] platform/x86: wmi: move struct wmi_device_id to mod_devicetable.h Message-ID: <20190122202859.vpmtekxrklrskaus@mok.nu> References: <271b1e903fa359c1100caba5bfc889183af02bae.1547827336.git.2pi@mok.nu> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <271b1e903fa359c1100caba5bfc889183af02bae.1547827336.git.2pi@mok.nu> X-Originating-IP: [94.234.43.8] X-ClientProxiedBy: PROXY05.HMC.local (192.168.46.55) To DAG01.HMC.local (192.168.46.11) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-01-19, Mattias Jacobsson wrote: > In preparation for adding WMI support to MODULE_DEVICE_TABLE() move the > definition of struct wmi_device_id to mod_devicetable.h and inline > guid_string in the struct. > > Changing guid_string to an inline char array changes the loop conditions > when looping over an array of struct wmi_device_id. Therefore update > wmi_dev_match()'s loop to check for an empty guid_string instead of a > NULL pointer. > > Signed-off-by: Mattias Jacobsson <2pi@mok.nu> > --- > drivers/platform/x86/wmi.c | 2 +- > include/linux/mod_devicetable.h | 13 +++++++++++++ > include/linux/wmi.h | 5 +---- > 3 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c > index bea35be68706..d7a2f5c8b959 100644 > --- a/drivers/platform/x86/wmi.c > +++ b/drivers/platform/x86/wmi.c > @@ -768,7 +768,7 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver) > struct wmi_block *wblock = dev_to_wblock(dev); > const struct wmi_device_id *id = wmi_driver->id_table; > > - while (id->guid_string) { > + while (id->guid_string[0] != '\0') { While looking through my patchset again I realized that I've inherited a potential null pointer dereference situation. This is relevant regardless of this patchset and I've therefore submitted a separate patch for that [1]. Further versions of this patchset will explicitly depend on [1], as this doesn't require any actual changes to this patchset, I'll wait for more comments before sending it. [1]: https://lkml.kernel.org/r/20190122200302.19861-1-2pi@mok.nu > uuid_le driver_guid; > > if (WARN_ON(uuid_le_to_bin(id->guid_string, &driver_guid))) > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h > index f9bd2f34b99f..ccc9bd4f32d2 100644 > --- a/include/linux/mod_devicetable.h > +++ b/include/linux/mod_devicetable.h > @@ -779,4 +779,17 @@ struct typec_device_id { > kernel_ulong_t driver_data; > }; > > +/* WMI */ > + > +#define WMI_MODULE_PREFIX "wmi:" > +#define WMI_GUID_STRING_LEN 36 > + > +/** > + * struct wmi_device_id - WMI device identifier > + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba > + */ > +struct wmi_device_id { > + const char guid_string[WMI_GUID_STRING_LEN+1]; > +}; > + > #endif /* LINUX_MOD_DEVICETABLE_H */ > diff --git a/include/linux/wmi.h b/include/linux/wmi.h > index 4757cb5077e5..592f81afecbb 100644 > --- a/include/linux/wmi.h > +++ b/include/linux/wmi.h > @@ -18,6 +18,7 @@ > > #include > #include > +#include > #include > > struct wmi_device { > @@ -39,10 +40,6 @@ extern union acpi_object *wmidev_block_query(struct wmi_device *wdev, > > extern int set_required_buffer_size(struct wmi_device *wdev, u64 length); > > -struct wmi_device_id { > - const char *guid_string; > -}; > - > struct wmi_driver { > struct device_driver driver; > const struct wmi_device_id *id_table; > -- > 2.20.1 > Thanks, Mattias