From patchwork Wed Nov 9 03:14:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9418425 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 3CB7D60459 for ; Wed, 9 Nov 2016 03:32:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 321FB28419 for ; Wed, 9 Nov 2016 03:32:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24C942897D; Wed, 9 Nov 2016 03:32:13 +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=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 842F728419 for ; Wed, 9 Nov 2016 03:32:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4JZr-0003zy-9p; Wed, 09 Nov 2016 03:29:31 +0000 Received: from mail-by2nam01on0040.outbound.protection.outlook.com ([104.47.34.40] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4JYj-0003EE-GP for linux-arm-kernel@lists.infradead.org; Wed, 09 Nov 2016 03:28:23 +0000 Received: from CY1PR03CA0026.namprd03.prod.outlook.com (10.174.128.36) by BN6PR03MB2884.namprd03.prod.outlook.com (10.175.125.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6; Wed, 9 Nov 2016 03:27:59 +0000 Received: from BL2FFO11FD039.protection.gbl (2a01:111:f400:7c09::199) by CY1PR03CA0026.outlook.office365.com (2603:10b6:600::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6 via Frontend Transport; Wed, 9 Nov 2016 03:27:58 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; glider.be; dkim=none (message not signed) header.d=none; glider.be; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD039.mail.protection.outlook.com (10.173.161.135) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.707.3 via Frontend Transport; Wed, 9 Nov 2016 03:27:58 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:1584; Count:10 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uA93R134018726; Tue, 8 Nov 2016 20:27:50 -0700 From: Yangbo Lu To: , , Scott Wood , Arnd Bergmann Subject: [v16, 6/7] base: soc: Check for NULL SoC device attributes Date: Wed, 9 Nov 2016 11:14:11 +0800 Message-ID: <1478661252-42439-7-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1478661252-42439-1-git-send-email-yangbo.lu@nxp.com> References: <1478661252-42439-1-git-send-email-yangbo.lu@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131231356785591208; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(586003)(105606002)(50986999)(5003940100001)(189998001)(2906002)(68736007)(104016004)(6666003)(5001770100001)(4326007)(33646002)(97736004)(229853001)(106466001)(48376002)(50466002)(36756003)(2950100002)(356003)(85426001)(76176999)(92566002)(47776003)(305945005)(81166006)(77096005)(81156014)(86362001)(626004)(8676002)(8666005)(87936001)(7416002)(50226002)(5660300001)(7846002)(8936002)(7059030)(61793002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2884; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD039; 1:Uo0XkI+eh6sHhMZsC5wXwuYc3kvq4RzQwOMiJuQjsKsAlvltpsAXVa6THg1d7iMG3EHe/PvQQOmUdF3VzYwWjqzfXBCtbheI4IuQ+relfSs+tqv3fpkJ5XX8tnW5S6pEwLyjhRJLafckRp9uuAwlXjeQFn7rl6Ib1KLNEquBTdnTi7gn2ighTZ1dxKUVtW84Y12+4m2sVXIhowcSpLrCW4DMUeUtfsMaxS5jAcIcjvnmgZAZnsmth4OtzgLwXbjJ/T67gQj6LIk5mJDXQDufakWpJkuzK133azmTZVFKIJjZQlM6txUx+kE/vper+lNa/ywc2J8jv/NPvB90WC7LWp+S07OBXaaSZJZcA6d4WgmuVupaPhugQ+/FptBdswqn1uExFsZUtIdstzEzud+8cbdAYcEAaA8h3UIPYtqSmNfvOTrO1UgpMtJI5ID1eAuiRJ/h8wpbi1R5WBuDyaBFHOwwIMGU5D9x044ZiP/C46MxGfRil8qWlyd1XVUrx8NL6mqgM9QPtpgsPv2orE3MrVDzQNk3hYx3VUSxPipglqGngdfp7Mzoax7ZSWH0C4pjWJbTpUjnsdKfyBGNMAciixAF2514JAnHJ3RXtIWKXbcqT4z1J5jg4y36bAeEJcGwmdjwaZlEXOTy/xiwM3i+gGw58rdyrJCxN3aTSedhDl0= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 366bd199-47df-4c76-03a8-08d408506710 X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2884; 2:7x8KVNognOktNMU4PCqhXhrCaD4gqTK0w+KgXm1ZcVH3GDfp7mzyXQo0+z9AoNB9TAFahk5EVY2+jVH8V5+cym9IZDgGN8+0ZD1VkUpiPcir5L4jBShsWa5KSxSV8F6jFukbmiq38oj2sSQiHS9UFSsqYbZ7EZ3nSxdEdi60CKXik0Y1sqrwzzrj8J1Us1FKpZ4y1vVHcjRaG4BsuJrQoA==; 3:7tWVa6Yc4+EWg1gpwmGOveKnLoLls9JDkrqtvy1gVhyAMHDWPW3732eOgST0F+k1q3DTAJjhLKtLD6fxrg3Gfs6gFipiSRfQhFAf4trb5fYBUvryfs+PTSzzl8ApDm7qFtqF2310hUTl/XZTLrHq0/aqsd7PyJfPVz5j2QMJFMayj91Pl6LBk0Mfc3JJCJOSpacJZismtwqS4ThMkttL76TkoM2sCUuoUKDywIk78meP4zBUqCOno2QYaylVVwdu X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR03MB2884; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2884; 25:fYqEMiR1lzvuo54XbtIVkjypPfw3mSDYR/gieThkzUH6Je641MCR/C/djxc3JWDVG7Bn5EIU4MbR9SyduFdDvmxsfrG1madG+ls51DK/nnNrMUYoUamUUQ4nrMPH3xPz/yqOURzqSBMwgQyWh+oMPPzRYVdu0PrBsSshiqD1Y3hUIe1jS8ngpOejcVVQkDRMkU9Od0DEcy6Q250lT1CROHzV3qeuRN3y4cVb23/zi7ROZfW6SmUXd0xtVdl4AIvBfqU+JqJ0hJ4TeLOotKF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yw8M3OgCoCb9S2mgkx3o5ZPDNj90ZPKXu5vxt0XgxVkP29wSSnHwRW1Z+aev6CxdNflw5AUlHP3sgxywnZkvIfU2J7hCUO9n/UU6wrp3p6XxU9BqtONygZykJxErjc95W4ajn+zv2/XqIC8j32YTV7HgAn1nujdUmnucsfnwJdLmqOcHZMP1CzvClV+hf6k+KRUvLHRxNkrqxYTlQYtudw7+n3+06iytnmEz3Rh67qmLStoJc2TN27Y3SlTn X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(13015025)(13018025)(5005006)(13017025)(13024025)(13023025)(3002001)(10201501046)(6055026); SRVR:BN6PR03MB2884; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2884; X-Forefront-PRVS: 0121F24F22 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2884; 23:/iBHg/9fpYoT+MFh/3eo07NXFTAXWQZb24rpUtZdC?= =?us-ascii?Q?H+uBrgeYnZ2E4PnTrzF7jMPYyuqmgnSdlsiDW6BHi3EKIM8Ae+uDMagvYlnz?= =?us-ascii?Q?GKoKbvRrofCUiq4Kjg793KSu5JXZepZ4J3IhNlXv88LeJSUk441lpH29hUcG?= =?us-ascii?Q?/RyDF8FYB0m1PVI5vWPnaQW/359j6yHKMtSi8YgO9L9UiXKApDeyeLUx+Sh/?= =?us-ascii?Q?wZy7wo9i3/VDhkBxYasKajYBLjmWG1T8Fy2PAWhoLkNcGR0V7EyZY2po5im3?= =?us-ascii?Q?dwIX6o6Dugoe4veWP2FcxwQ/ZUfUIawEyi0nZX2t5LnGy9lr6xu5RpHCCukj?= =?us-ascii?Q?YF05hZLYh/tAar6w+NZqTQBt9ipdfHUkiPMjFMwk8sc4vUQjsH8h9FZrmBzX?= =?us-ascii?Q?1NyRgtxqDHycMw5ihNCEFp2d6WBDi4GlG9BRe1GtKF6N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LhdivBvw5OisvqaKuMJ+jjd9YodS9RgBateiAyTmhlXzT6Q3SerHo768svTUJEOHqETb5bMFXfzJYAi5WYy/ZcG7BQiAsmBKc7yItLbDIT4mArG3Pe7RmR6oXi2BUlkzGUYCaCaMVD1MRG8NxtlRNI6deWoeO19; 5:D4E7M9eAQzrjaBHyaRn7UHEAydlKLn1RRBqIqWXzAhUChSVyzzO91ihhmJiJcfl3+KvrCfSivBEfIugCndhPDEl2q4lOEaqEIgTcVgQ+dQpHhHMFil7Syqp3nQYLssczESa1RtHEJCHfKt35QuR+pHHGi8Sq5qIxp3d2VyTGTiM2UIw9+NTLsL7DlrpTtzGf; 24:K072k6+o/k6LUAkliARRdjYBqJkFTcw87asBQfddyqoUGFkEwaXjehn/9YNPGzw8j1IAL8C5qSBRbhf8RLIRurInTFFOZkWGlusoe3fWTSo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2884; 7:yA8QtOModRgP/KKJLOb0VhogSW4+vaXTc9GBjmFsyE6dha+aK0JOBSKJ+IE2yvqaoz4y9PwfqZ0CIqLCrrx6WsfX9XhHmEiW1mDjErg3aiqQfqIn5MlRWL9nXHEigh4qRw0Rr71r/Zv4+sntuPts+3nokBTSqlipqXi+9OoH668Kmpi4ryZ6dfegWk7DX28s8tTTFQt5+woq2+kgJI0ilAAKJ6dwtH6nPN/MMTwlocgQJzpcpv83kJIizV7r/ugPlmUXaBHbMaQS6G+vtkZsVMrJn1PtpCImzilRnoAQjCdDW3uaSAej6/PEXC51l0s6x5O4hshKcRAXry8CNbqr/6fu5jQotANUiV6N0IL8Log= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2016 03:27:58.1535 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2884 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161108_192821_756361_2FA31858 X-CRM114-Status: GOOD ( 16.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Geert Uytterhoeven , Greg Kroah-Hartman , Xiaobo Xie , Minghuan Lian , linux-i2c@vger.kernel.org, linux-clk@vger.kernel.org, Qiang Zhao , Russell King , Bhupesh Sharma , Joerg Roedel , Jochen Friedrich , Claudiu Manoil , devicetree@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Leo Li , iommu@lists.linux-foundation.org, Kumar Gala , linuxppc-dev@lists.ozlabs.org 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 From: Geert Uytterhoeven If soc_device_match() is used to check the value of a specific attribute that is not present for the current SoC, the kernel crashes with a NULL pointer dereference. Fix this by explicitly checking for the absence of a needed property, and considering this a non-match. Signed-off-by: Geert Uytterhoeven Acked-by: Arnd Bergmann --- Changes for v16: - Added this patch --- drivers/base/soc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 0c5cf87..0e701e2 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -167,19 +167,23 @@ static int soc_device_match_one(struct device *dev, void *arg) const struct soc_device_attribute *match = arg; if (match->machine && - !glob_match(match->machine, soc_dev->attr->machine)) + (!soc_dev->attr->machine || + !glob_match(match->machine, soc_dev->attr->machine))) return 0; if (match->family && - !glob_match(match->family, soc_dev->attr->family)) + (!soc_dev->attr->family || + !glob_match(match->family, soc_dev->attr->family))) return 0; if (match->revision && - !glob_match(match->revision, soc_dev->attr->revision)) + (!soc_dev->attr->revision || + !glob_match(match->revision, soc_dev->attr->revision))) return 0; if (match->soc_id && - !glob_match(match->soc_id, soc_dev->attr->soc_id)) + (!soc_dev->attr->soc_id || + !glob_match(match->soc_id, soc_dev->attr->soc_id))) return 0; return 1;