Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6036147imu; Wed, 30 Jan 2019 07:44:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mVeABYv8CliNl7f/OiiAhKPGqK+hZPzshAuWfLtfvqwisw1SNaRQymv0CpCOo6Ducy4fN X-Received: by 2002:a17:902:5066:: with SMTP id f35mr30982158plh.78.1548863076831; Wed, 30 Jan 2019 07:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548863076; cv=none; d=google.com; s=arc-20160816; b=UZMAREvjREZ+w/9XQeKoR+TILeD0U0CJzp7xW9eFw6OBVXIGJMHtG7m+gJJE01xpTr Vf9a3uz9CkVpuWy/XOGqrazR4PVucVwxDP/4lb0CFUJIztXtYMaAkhFbjXXpWFlHN0UW j3PecuSOIg0BQ/rhQ/En0RaRa59Rn8N+avD8eM985zxPlfXgxPxPxfZkXKVzFKV596Al nudwDpL6J1nrfBDTMmsW/gmay1aJscVbr4sDyJl3QVgRBQXYbRuZT5YL8IPWtR5WaXx3 7NzGbPzLtOBo1wjFzRgJPQ3KBQm+J+whQEjIGhvDcr1Bif/k8GL+MSDOXG0Cl2JbXlLB Q8qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jkWcEhfUSaW3+qq2QeySS+iZcEjyvZo8uXYJm1mSdpo=; b=0mpzhSDBpvdbGYZB+zKv+gp4oloSIx9BbAFZvlf/1/zf58pvfeVtWdkl4FJD70tSkD FUwJFDfeCqSMwriz5CaIFjwHMkqQLmkEReo3shcbvO5kdWWCtFuaERrYLsyAKEnCmGfT tWgBTz0AUHd8XzTmX7TEBYe6gHsTuuXdmoJYgvznMM1hpDfToHwMttjcHypvCtuBubqe gmL1gR8e3RaqE+St4daOmVaDbLDlFVkiwfT6ORSxcjX+bWiZJpoPoeliMuw/J7EprQE8 goqWPwfUdckNPRQSeqsJbQ3U9g8SoXu7W7t0FtxvAynJFSKffwAs1Ve9P0mp0HAD8CJF MdNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="kfdgr/EV"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k72si1576674pge.310.2019.01.30.07.44.20; Wed, 30 Jan 2019 07:44:36 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="kfdgr/EV"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731561AbfA3Pnr (ORCPT + 99 others); Wed, 30 Jan 2019 10:43:47 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46037 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbfA3Pnr (ORCPT ); Wed, 30 Jan 2019 10:43:47 -0500 Received: by mail-pf1-f195.google.com with SMTP id g62so11562653pfd.12; Wed, 30 Jan 2019 07:43:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jkWcEhfUSaW3+qq2QeySS+iZcEjyvZo8uXYJm1mSdpo=; b=kfdgr/EVYnERKR4XZeInirT0flpg3zeEXsmvhuOivw1msNdthZFrAuUtDlGp4TUYq2 Cx4NEXGTJNAicqol2w2L4jXZCgPnURnBFAwxpMl0+B6C/K0Gi+VyihV1kdSIUdNJRjsV +EbgRGYpryM7yd7zLKYn80gRTeXUxFXZfa33UklMJwn/QK0A+3NH36k7jzn7Mw/+Gvrr IX4UIon1L5Ef3tr82mhPRtSmKDGfN9nAIMJZA6r8HQTrTDnXL7ASd6jS5OEMoOOvNCI2 L9buf8aUf10yQP0jWrh6D66AOA5uwccZTq9HDetIjS/nmgY3gmQtKADky3amEc0fPo0D 0VQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jkWcEhfUSaW3+qq2QeySS+iZcEjyvZo8uXYJm1mSdpo=; b=oEvpCeqKNyOsMVtmPIH2h65VxDb3GPsT0wrne9zXo0qlsbyid2m6gdfhB1D2xJWpL1 NvC8XDQkCjGJ7jTlaLspXdJslTsfp/eKKp0YnUUEiKkyOtcqmY/62JAm3As3RM566FlK NXMUd2mcIuaWSlluQ7rzQOZ/Fb5GEvNK7HaqaKZJ0tEp/c4tvjdISVGT1FntH6JDEEDu +6m/OJUj+JkMO/HnTumLFr/J+FRgiWpN+pcVxGjuW3LhpG4LaUqHXJ0jRuAn1p8ckWbQ 80ZXD6IbfrI3zZ/7lzhoqFqFazsKLCae1Raqnh35zh4RUZWbXk/LtvGoglWEuY6PJG4j 02+A== X-Gm-Message-State: AJcUukelX2zt+kduZ6ygfP73OD3QG6taPubAEq+B7XdkzozXALMUC54Y reNQ6RuZMq532r+yfDD8tzSJKz6PAG42H835fkg= X-Received: by 2002:a63:f615:: with SMTP id m21mr28500777pgh.428.1548863026673; Wed, 30 Jan 2019 07:43:46 -0800 (PST) MIME-Version: 1.0 References: <20190130151424.28140-1-2pi@mok.nu> In-Reply-To: <20190130151424.28140-1-2pi@mok.nu> From: Andy Shevchenko Date: Wed, 30 Jan 2019 17:43:34 +0200 Message-ID: Subject: Re: [PATCH v2] platform/x86: wmi: fix potential null pointer dereference To: Mattias Jacobsson <2pi@mok.nu> Cc: Darren Hart , Andy Shevchenko , Platform Driver , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 30, 2019 at 5:15 PM Mattias Jacobsson <2pi@mok.nu> wrote: > > 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. > Good for me, thanks! > 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 > -- With Best Regards, Andy Shevchenko