From patchwork Wed Dec 6 16:41:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10096505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A0C72605B4 for ; Wed, 6 Dec 2017 16:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D9B4295E7 for ; Wed, 6 Dec 2017 16:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CEFA298B9; Wed, 6 Dec 2017 16:42:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A602129702 for ; Wed, 6 Dec 2017 16:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752742AbdLFQlq (ORCPT ); Wed, 6 Dec 2017 11:41:46 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:50166 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752478AbdLFQlg (ORCPT ); Wed, 6 Dec 2017 11:41:36 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 25BE7607F4; Wed, 6 Dec 2017 16:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1512578496; bh=pGMzOA+COJvU4JWDuL4L4dnCiGM03U3X4gPPvpW4ZjQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=C5ojrObcywRAivrTSF50gcd48frF2O0zRS0ND8rCmM3aVqLOTVlfLn7l7OFQjjU8S IsKeO0pH8xEspM6P0TYfJrnxYvt1YFVjs9O0YyvopT+RKujOx7u02HZeYitht+Yi4X Igpqozbb4jUcRJl9LpGUG/aM1ho31UBakMscUotw= Received: from [10.38.243.110] (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 516E46022C; Wed, 6 Dec 2017 16:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1512578495; bh=pGMzOA+COJvU4JWDuL4L4dnCiGM03U3X4gPPvpW4ZjQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=dMMuRrgPmDzV+zyWtnINT4/ChaYRWSkLrsbBinD2k76vj4uJGs2Cc7q9a+R9cncrT 4p2+1x5hF1xsKHha/AEW/BdQhOiHb+7QxT34gHHU2/2Bb9cjW41Yr6l63m/+ORB4yc cJfYrlWdhO0Qra0X8rUciuS++xhl5SZgvWH/LDM0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 516E46022C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org Subject: Re: [PATCH V6 2/7] ACPI / bus: Introduce acpi_get_match_data() function To: "Rafael J. Wysocki" Cc: dmaengine , Timur Tabi , "devicetree@vger.kernel.org" , ACPI Devel Maling List , linux-arm-msm@vger.kernel.org, "linux-arm-kernel@lists.infradead.org" , "Rafael J. Wysocki" , Len Brown , open list References: <1512493493-6464-1-git-send-email-okaya@codeaurora.org> <1512493493-6464-3-git-send-email-okaya@codeaurora.org> From: Sinan Kaya Message-ID: <218a717f-7fac-41a1-86e2-19f4d99a7f52@codeaurora.org> Date: Wed, 6 Dec 2017 11:41:33 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 12/5/2017 5:04 PM, Rafael J. Wysocki wrote: > On Tue, Dec 5, 2017 at 6:04 PM, Sinan Kaya wrote: >> OF has of_device_get_match_data() function to extract driver specific data >> structure. Add a similar function for ACPI. >> >> Signed-off-by: Sinan Kaya >> Acked-by: Rafael J. Wysocki > > Not sure yet, sorry. OK. no problem. > >> --- >> drivers/acpi/bus.c | 12 ++++++++++++ >> include/linux/acpi.h | 6 ++++++ >> 2 files changed, 18 insertions(+) >> >> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c >> index 4d0979e..b271eb1 100644 >> --- a/drivers/acpi/bus.c >> +++ b/drivers/acpi/bus.c >> @@ -785,6 +785,18 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, >> } >> EXPORT_SYMBOL_GPL(acpi_match_device); >> >> +void *acpi_get_match_data(const struct device *dev) >> +{ >> + const struct acpi_device_id *match; >> + >> + match = acpi_match_device(dev->driver->acpi_match_table, dev); > > Shouldn't this check dev->driver against NULL before dereferencing it? I'm adding these checks. I realized that acpi_match_device() is not validating the ids either. Sinan --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -789,6 +789,12 @@ void *acpi_get_match_data(const struct device *dev) { const struct acpi_device_id *match; + if (!dev->driver) + return NULL; + + if (!dev->driver->acpi_match_table) + return NULL; + I'll hold onto posting this until I hear back from Sakari.