Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934215AbdHYQKF (ORCPT ); Fri, 25 Aug 2017 12:10:05 -0400 Received: from mail-by2nam03on0053.outbound.protection.outlook.com ([104.47.42.53]:42176 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934127AbdHYQKC (ORCPT ); Fri, 25 Aug 2017 12:10:02 -0400 Subject: Re: [PATCH v3] irqdomain: Prevent Oops in irq_domain_push_irq() To: Dan Carpenter , Marc Zyngier , David Daney Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20170825121409.6rfv4vt6ztz2oqkt@mwanda> From: David Daney Message-ID: <075689d0-93af-2ff1-d71e-c7914ddd3935@caviumnetworks.com> Date: Fri, 25 Aug 2017 09:09:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170825121409.6rfv4vt6ztz2oqkt@mwanda> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: DM5PR07CA0031.namprd07.prod.outlook.com (10.168.109.17) To BN6PR07MB3490.namprd07.prod.outlook.com (10.161.153.29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f124527-e7ab-4949-9f44-08d4ebd3bd77 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN6PR07MB3490; X-Microsoft-Exchange-Diagnostics: 1;BN6PR07MB3490;3:Bv6uXE+QassPkUiHJbwKEQxd8/wU8j+b4M90Ya8fRIdIWXAVeI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UBmTutJHBJNMT82+UdwZBijUYyO+fyHkOW3ZA2XHufrkhNMfpBaJmIKVSDc56DL0wbg5YhKZMl0ilSIRePtIjZab8/5j9HtVUqnJ7GtbxRnUnbyzkOxzZRtTqzC4TnTH+t4djNYcaYALhsab2qOgG8jimal7R6ya8Dd+QEs5MW5XzmUWNwGizhwuCLXbSaHTW+UeORo084WhQ7Qg7/K/stP4IcTJBuaJR2MEXeeWDc77ikRKc/LTpMWv2Q4j25jaGh65EJ0aTlM+vZM4S94a3ms8CSqKbGv2rIHwqJ49XjQv5aVVk3kY3+mMmdYOERtl1bpLXl095eq2iUsSVODL0ljzY1IOOdJoyUFZCP36lHRSQlF7z8eNns6gjt5jRKOqeVmxH6FpIFMdgp8CvPrDqm/8=;4:Y5w2vKtNrI7SMyf2cfOFPlCSKSHT2UiNPflPbDYsBr28dCBOBqbLbhJS4Do5Zin7W9eFtpgKGgr8KssJK3JCJ7urrPXGdzn42dhenTFeZzuq03nYGizi/kmChgpc0i6sBELrNH5ml/baj3jqvWdRoBVVlIW6eMttToDKbQbNp/xRzNH4TgjGhj4ZfhYsZ44szYMLqY4e5xdg4O2rneABw9V4S+LPiWmvd+mE6E24TnqE5IVKNFMyUiXEJAvUz1nidimqR9CzFnAovgLO1r3+YFKe4AxfG9LfSsqU7Ly/Rrc= X-Exchange-Antispam-Report-Test: UriScan:(146099531331640); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(100000703101)(100105400095)(93006095)(3002001)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR07MB3490;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR07MB3490; X-Forefront-PRVS: 041032FF37 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(377454003)(199003)(189002)(24454002)(54534003)(42882006)(2950100002)(69596002)(478600001)(4001350100001)(229853002)(6486002)(6506006)(25786009)(36756003)(6512007)(101416001)(81166006)(4326008)(72206003)(81156014)(83506001)(53546010)(6246003)(47776003)(6666003)(53936002)(8676002)(31686004)(50466002)(230700001)(105586002)(53416004)(3846002)(33646002)(7736002)(189998001)(68736007)(305945005)(7350300001)(23676002)(31696002)(64126003)(66066001)(65806001)(97736004)(42186005)(2906002)(65956001)(106356001)(5660300001)(65826007)(50986999)(54356999)(76176999)(6116002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR07MB3490;H:ddl.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@cavium.com; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjA3TUIzNDkwOzIzOkEvaElNUWE0d2F4R2trNVAxYmMrV2hKZ0ZW?= =?utf-8?B?R2psdm1uZDhHUWthUEFKV0ZjKytKMTVLanpXRTdtNElUWjhCdi9HWkNDSTVu?= =?utf-8?B?OXZkWXFhMWU0OHJHS1g5L2k5dTlzNWlDeVNMUzdGd2Y3MWVCU0xXcUk3TXpX?= =?utf-8?B?NGZXMXZHWElYV2hzWHhRSkhOV2RLZFAzV2pVc251NSsrQ3pxemE5VThLRFhj?= =?utf-8?B?ZnRjUnBSamZzQWNGN2xIeDRxbzFrUzB5MVpMQXFnS2YwS1Y4UTFBN3dhN3dM?= =?utf-8?B?S3JOdUQ0N2dGMGdITTFJeVNiTkhnZkpBcFAxak05NktKTWFhL1IxWE12S2Ny?= =?utf-8?B?Y3JrK2J6Ymo3Qi9zb3QrdmcwOVpKSkl2KytoN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RuwLy1yEllMUnU3+j2muhJX88BhmYNRsoO0WgPCwUDhc2g==;5:CML53XCIUhDK+rw4cjD/C9veDg2mMAQ8QEqiAeaEAdmk8H5UkIgc4kKGMHhXFaBgpNWXlgfMl9JECJhSg6dC+5fwJnsg3r5xGl/JGkmg0DxizT6+/GXAhy6smaXC9PpBwOInFbGAH7YZPa7ectanKQ==;24:rbtXLRWVemraxlQq4I74M6vaO+NGmaWdlEFFaJp7jtUyfBHieyzhbespTuIcvkzktvOTtv4GAJH1WdJKrkkMVAgSFw/R5u8GpUQxzisj0Xg=;7:shcPQWjzZ88aznP5jYsJdIjyKkj0amSkYgGXSQV3ZYP+rfHYvitkGyahp/IjxgkZTVHeO34wwO7iq03dVCxq74cyQ1rmFM9Q1cscBqJd/WWuSMnfOQzoyCqAQ8gOfvwu12O3MCZ/uiO4K74PTR75euSUm6F7sRdpw968rjxhrYUgQlzlP8iOBq5Y4PdqQ9FghCka9/C7YdqRLjUKdQ1OQtuDGVx7BXWUEd5+CYPlxwc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 16:10:00.5598 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3490 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1287 Lines: 39 On 08/25/2017 05:14 AM, Dan Carpenter wrote: > This code generates a Smatch warning: > > kernel/irq/irqdomain.c:1511 irq_domain_push_irq() > warn: variable dereferenced before check 'root_irq_data' (see line 1508) > > irq_get_irq_data() does sometimes return NULL pointers so this seems > like a real bug. Let's fix this bug by moving the check for NULL > earlier. > > Signed-off-by: Dan Carpenter Thanks for identifying and fixing this. It looks plausible, so if it compiles without error you can add: Acked-by: David Daney > --- > v2: Redo changelog. > v3: Redo changelog again. Make it imperative. > > diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c > index b9c688944429..e84b7056bb08 100644 > --- a/kernel/irq/irqdomain.c > +++ b/kernel/irq/irqdomain.c > @@ -1505,10 +1505,10 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) > if (WARN_ON(!irq_domain_is_hierarchy(domain))) > return -EINVAL; > > - if (domain->parent != root_irq_data->domain) > + if (!root_irq_data) > return -EINVAL; > > - if (!root_irq_data) > + if (domain->parent != root_irq_data->domain) > return -EINVAL; > > child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL, >