Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6007562imu; Wed, 30 Jan 2019 07:16:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IYMfwHROzGNiSI70MApaluM0ST3ouZ/EMW0Gj4eniPS4rATM/9Hx1AtqsSvCpB1g/TJMyZM X-Received: by 2002:a62:9305:: with SMTP id b5mr10280486pfe.10.1548861394027; Wed, 30 Jan 2019 07:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548861393; cv=none; d=google.com; s=arc-20160816; b=LWQ5mwm+Ghi+ERUFKwX1oBsHeapIgdYaQdRGywb27wqGwvAR4DUi1Xc3IHMu/2gWzV RxGKWs8q61Zu7AZiBgnscTHE0rXEqWAIDGL5pGKrcvfDleii1Y8TYQ51cpCcopMREv26 f7iWrxPaWGSROmMHQ3R0NCXSFgEHu6WuzhoLhR1cR+XceVhQhtuI2UpAlr8+LeHpPH0E nPuWGpWs6hUNx+YSm5rZ2KVnwg4Z5Ot9NZSn6AtMf76d8ferfDuJR+vPzyshgTDGbvuj i3hDlFSDBfrsLJMVD6RzR7sr1C67eq32vTzJBbLvRBBspJ3C21VFb5hI7WA6yobQ8fxa VfSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=K8dWpANBFsEAe7atFpkEeeRF+yLh6U+sam9+3+tF63M=; b=OAViy5J6u7bqewRbmXW6o5SnlcaNXb8LzN0qdb2IixZ8FddzpGVw9DSQULA48j8QrK RO4bsOpPEFCe3j3gtRbOwm5iqOANW77IqnZFyb9i2jdxcrBmoA53zU7YrWMuu8VEK/Ue Th1tnPD+7daVdVSOCwdO2ycQidfB2ZCPadGwHOaSZHZaa915WzoRq+G6IgrUlrv23C9B PexmVhF+o9XOiSQ0ZQ7DazjU3BM9C46XKLql/eeuutQXv2yYlFqNQwYpmJ3HTOpv3rJ7 he/kTcEPufNnBfHKa0tUB14ZneUMUne9FKslF/rGYj4xe9hr2KuP1KtN1z9L0n+zUzsq IRdA== 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 e21si1509057pgg.571.2019.01.30.07.16.05; Wed, 30 Jan 2019 07:16:33 -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 S1729823AbfA3POn (ORCPT + 99 others); Wed, 30 Jan 2019 10:14:43 -0500 Received: from proxy01.fsdata.se ([89.221.252.211]:29706 "EHLO mail-gw01.fsdata.se" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726455AbfA3POn (ORCPT ); Wed, 30 Jan 2019 10:14:43 -0500 Received: from localhost (94.234.42.28) by DAG01.HMC.local (192.168.46.11) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 30 Jan 2019 16:14:31 +0100 From: Mattias Jacobsson <2pi@mok.nu> To: , CC: <2pi@mok.nu>, , Subject: [PATCH v2] platform/x86: wmi: fix potential null pointer dereference Date: Wed, 30 Jan 2019 16:14:24 +0100 Message-ID: <20190130151424.28140-1-2pi@mok.nu> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [94.234.42.28] X-ClientProxiedBy: PROXY04.HMC.local (192.168.46.54) 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 In the function wmi_dev_match() the variable id is dereferenced without first performing a NULL check. The variable can for example be NULL if a WMI driver is registered without specifying the id_table field in struct wmi_driver. Add a NULL check and return that the driver can't handle the device if the variable is NULL. Fixes: 844af950da94 ("platform/x86: wmi: Turn WMI into a bus driver") Signed-off-by: Mattias Jacobsson <2pi@mok.nu> --- drivers/platform/x86/wmi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index bea35be68706..b0f3d8ecd898 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -768,6 +768,9 @@ 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; + if (id == NULL) + return 0; + while (id->guid_string) { uuid_le driver_guid; -- 2.20.1