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: 10096507 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 7FBC860210 for ; Wed, 6 Dec 2017 16:42:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 706F524B48 for ; Wed, 6 Dec 2017 16:42:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F12227F9F; Wed, 6 Dec 2017 16:42:30 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 70CB82988F for ; Wed, 6 Dec 2017 16:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pxO/m5DS5eeLsH25Mye0AFFsT4wPYWThH6447ps5zEE=; b=Kvu1ZcGaqKLZYa 0xk7ySxIeu8voBcIM9UqmJDr3EkueDKujDpdBS3VJY72zqHRSc161wKBlTut1vu5ZNYkT3DLLmymR OPYn9g1XS+bmaDqfxleNynNyIK7YTVFaLVW+7wmKs/+1rlRU3zAVV8WmpRET/Gq9ML5bxCYyuOzxn Lg7rg87NKkzYtnbFOG0Yuum4D9TLLaMeTX39unIsD8+F6R62spd0IT7p9Zhc86mnPZTeu6Uf5Ybh/ C1KzjPlhQyim0PfoC1iLX/oXZmEB2ZTIIg0KhNIgyFXkOELdIiAoyZeyVFg5Gba+v7sX7JlTEnSAO nsQMmmbUYSh/ZaNI4EeA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eMclz-0007Mk-Ly; Wed, 06 Dec 2017 16:42:15 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eMclh-00075D-5X for linux-arm-kernel@lists.infradead.org; Wed, 06 Dec 2017 16:41:58 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B93DC6081C; 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" 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171206_084157_252821_BFE12E20 X-CRM114-Status: GOOD ( 10.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , linux-arm-msm@vger.kernel.org, Timur Tabi , "Rafael J. Wysocki" , open list , ACPI Devel Maling List , dmaengine , "linux-arm-kernel@lists.infradead.org" , Len Brown Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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.