Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752976AbcKIDnK (ORCPT ); Tue, 8 Nov 2016 22:43:10 -0500 Received: from mail-bn3nam01on0041.outbound.protection.outlook.com ([104.47.33.41]:30064 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752246AbcKIDnF (ORCPT ); Tue, 8 Nov 2016 22:43:05 -0500 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; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:1584;Count:10 From: Yangbo Lu To: , , Scott Wood , Arnd Bergmann CC: , , , , , , , , Greg Kroah-Hartman , Mark Rutland , Rob Herring , Russell King , Jochen Friedrich , Joerg Roedel , Claudiu Manoil , Bhupesh Sharma , Qiang Zhao , Kumar Gala , Leo Li , Xiaobo Xie , Minghuan Lian , Geert Uytterhoeven 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 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 366bd199-47df-4c76-03a8-08d408506710 X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2884;2:7x8KVNognOktNMU4PCqhXhrCaD4gqTK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S: 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?1NyRgtxqDHycMw5ihNCEFp2d6WBDi4GlG9BRe1GtKF6NkbdeXG26Jvi90bqs?= =?us-ascii?Q?asvOVqGJSikRd6sOm9akAWaXJ6v34IQcy2ligEiE6m+FqweYRvTaLjiXdPkz?= =?us-ascii?Q?P89Mzz86SOKlBXhKju3ghLiO/RcqcPxRZsNSiE/pvlwNAFWUHorKHyvXLzNH?= =?us-ascii?Q?Ywb/ETVzdwAOKZ9pfDefVyXdCHNdtl4NyZpmA/nZIWNy8tMeAYhU/Bp+fMUB?= =?us-ascii?Q?PqFm4u417vYlZuki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hHMFil7Syqp3nQYLssczESa1RtHEJCHfKt35QuR+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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1627 Lines: 52 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; -- 2.1.0.27.g96db324