Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755494AbbKXWty (ORCPT ); Tue, 24 Nov 2015 17:49:54 -0500 Received: from mail-bn1bn0104.outbound.protection.outlook.com ([157.56.110.104]:20448 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932203AbbKXWsG (ORCPT ); Tue, 24 Nov 2015 17:48:06 -0500 Authentication-Results: spf=permerror (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; From: "J. German Rivera" To: , , , CC: , , , , , , , , , , , , , , "J. German Rivera" Subject: [PATCH RESEND v3 09/11] staging: fsl-mc: Fixed bug in dprc_probe() error path Date: Tue, 24 Nov 2015 16:31:22 -0600 Message-ID: <1448404284-22258-10-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1448404284-22258-1-git-send-email-German.Rivera@freescale.com> References: <1448404284-22258-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC014;1:h2hlv7ix2Es4g2W6PxqHIhIS3lN7PLQUCBl6BRi2vfxG+aJTMoGKnSTUyi1o+YRHRfVGlUYgZYWSj/60RVhojjvkgEhjY45biNrWWQVFZNSEJc1kEh2tmeiWgsfW5kGxwKfc7gLBSqMIkRzNaFAsUkKJrIv9BGQ1FpyjXV7pjnL41U70Fe83VF51kRZ/Y4b0jGwIFFNfKroM1kJRKX704pdKRrZ6V4b7BFhmi1pJC6nQiDRS3S035RgKZu6rpOks2Gfo2gMOxlZXhvHVUZXmPnRc0NjbNVePowLSpMTBLEUEmI5LS2UdAUA3V3CV1rrUMxr7yobBewGjeThzaRbvHpWcGmy9DOuDZ5vONg4y7LDPWVUTdDphKr3j3G4sVww3c/8jndUYH7pgpU/3Wf7RpBu10Rk2QqK3Vwg9uUBv+VnKwByfoxHServb12d3MlQlJZg5mHuZ/jnKnSPx9v+ifA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(448002)(3190300001)(189002)(199003)(229853001)(86362001)(2201001)(106466001)(5003940100001)(586003)(5001960100002)(107886002)(97736004)(5001770100001)(87936001)(76176999)(189998001)(85326001)(2950100001)(48376002)(81156007)(50226001)(92566002)(47776003)(50986999)(50466002)(6806005)(19580395003)(11100500001)(19580405001)(5007970100001)(77096005)(5008740100001)(4001430100002)(36756003)(104016004)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1446;H:tx30smr01.am.freescale.net;FPR:;SPF:PermError;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1446;2:RRKdZZWmRmPKy2R0PvzZdCvxZvKMjseZRnmgaqskG22oJmsswU6MOhtODGyCyXRIjVS1n7boqbR5s8m4PFPg3PgXOHd1oqhqQjLQhcgOqWR+8OamnEBw+vqSnDpAXxJHYDPgwASIstS7Io2rDvG25A==;3:bEhmZJNcZ4c12umXYWCLnVH2JC38CpITNDyi78NLoo0uSKGjEzghiiFDNlZIzkUsUkpT52DHAlGxyLye7d3sAWHfFmTLpCn2C3KKNcZ0FY0/MJaB2OPjHG8UfzsC1rhoejgIXFZkYtezHA2E65p+bhMD74cFDOqw5Elnv5XEaAUkjDPKMOed+P4gBe1CAJ5ugmvW7MfA5CpIons8cergDyR3C5Vo3ZC5dqly1bWFEWM=;25:yzk195K4JZlywWFAtLU8Uk7IADShyZ3yW4xL7Uc3sTN7o50RTvLLUnl+APIgFO4YmplXZwqhcSUMGWklFez9JWkTW3n7UtokVOT3kDq31LIB5ktI72jeM+MyXiuTWCtvsTUFfq/7onu9+UkKCWjYXvSwZEmLUVq1P4V+0JI+1yZbXicioDNazRMPSpLBBXfu9KwRRTynFoFkrlhKmaD2+mlLTdlkluN+km2aH95szftob74JQYNYxGN+nQnGkPaqf6BUXYomMuh0AgsG7h7iew== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1446; X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1446;20:ab7Z9uyma9a/+MAmkpNjPKRM0Y/eoCV7m2+pANXW5vxJs1DTanzdsjjlGRkxmqQ4+QeGopUkoUftuNPP+GQfhfjf0WEaaqy4KOq/felZ52P31y/P8XXFdJfLJBch8rJc4S25O/ZI1RrqqYDXOsMS3wMNKSE4Vc1X6m8AqQLp9+WB3IX6Uj3MztE8dvtO1QbqfzWXnj/5fdK8/5+XUM14atWZ4znJX2dt2oD0BmjwEpmQY1KL4zBN2gz04XYxTGn8ZupT5a0jGUDLwtF0ZJ5IfUxUjYm8C3J+2dgI40bt9NXQSTdsqKUq8oxqotL7QdlZDlsJSTVyznvrbi362zUsS6LgUMevqICslGu9oy2F2Xk=;4:gZMA9coqKtpsKby6HOVKh11rjxa9zjLhDCDekDefRzDi7cBj5jvuVHlFWkgLSJMjGd7b+zujQLCYvAYpZ1q0aS/9U9CBB8jK347Dh7P/LHQ4Sv+R/F4Mj02TRhlm8AeUIY+WCDoLmYPdVbyBtG55e+a9JpBGcR5TNhCoc9GlGT6WzLWP0qenMmzOLz1Zuea7SbggRc31Aj4agepO4+iKyOjebxF8QkXxcO43ilt+rxciv/rw2PMOgqaJmcfxInFFOtI/vgVc5S8EdEyuiIqTv/LeuoXLfZuwcagFg5X2j/oNanDXFE85gK39lWI/spg1WQUwFdmwRrQsqdmK4El1INSP/bl30BTKFEMaTq9p6gSE4HTmM2DrqFFeDHA3XmihijLyoHoGqJG51syID3AzZ88oVvlT4+emOZGsolt0nz24cxRCT72+aJH6jadDtpZI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046);SRVR:BN3PR03MB1446;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1446; X-Forefront-PRVS: 0770F75EA9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR03MB1446;23:9bvYC2Sa4J2OIIBB+fSjikILLljRU+UEvx4qFXcnR?= =?us-ascii?Q?IhxRqKAwxrb601VQyG5zSY2jSQfwn/u1EhJ9Is3zQS+ADIjmq7CU40fKa4TA?= =?us-ascii?Q?uF0+srKCTgVoq6DBNoRsDjvrTv819eveuE8CMGDMlteImGij8yJZVwlrfgTJ?= =?us-ascii?Q?WNX4xxtqJ5O3qtDqupaIPpccebCBaxsOOaG6BXtQ/jHbHG1qsTp+GQpGc2DU?= =?us-ascii?Q?5tqojX9og1CTBX2LIol5fPej3A734lutm2S15MB6C3onZVYyJWKQK9YnagPL?= =?us-ascii?Q?2JSsrIAE9M6NrWRDpObBMFMfL+4s1Jc6pqHfGOhDNocZuSSa4QfrF1I/yVzC?= =?us-ascii?Q?huQglSjMk5lWdjzpYbT3XKnvNXPlX4HoWQB2cQovQ/EP/TSJ+niA6R88DPRw?= =?us-ascii?Q?/2E3LDSq2dPNajj4FwAe2gf3u3YgC1Osra7+ojfJLeJ4iGLeH7wyW3TkZgeV?= =?us-ascii?Q?0CPO15koetdzBanU9mabVxEBMLCpLSUBlDWSVZ8t5H7w4T9E3nnyrmiATSkb?= =?us-ascii?Q?6PKhCYHF1vXa3GWhrl9PtSguMj7O7lUwDlIeGYDmnWLtoSZgxGLozs/GwgM5?= =?us-ascii?Q?PYeL+0b9dgP2yQbv9ocgNJG5wZLSBHpm5gy/xifGKW8oELqe8L8xRIV0oZ0d?= =?us-ascii?Q?XlLdHTOgJgsjH4pjRmXvwkk+yE2KyhwrkdjY8ThcFEA+fRYX9RlAr5+VHOVH?= =?us-ascii?Q?0WGnLKSRqarH/3M1nuorcK1p/pFljQCQn5dQD+yRISoFE6DeZMEFwLIDicFM?= =?us-ascii?Q?U+GYfbE0L/ReAbs0+/JoZcnjpr3OV6zoDzHW/ECr3j3/HyYGE3Z89obi2ydb?= =?us-ascii?Q?y89zF6aVGo6Scd+49gh2yV8zpp0FB00jHOiyr/aQpgFepgVVsB131i1gxyF8?= =?us-ascii?Q?aTh0urCvbn7geeKiK1XydJSEONTc7NRD43nb3NYZgQkxfr4zQbXHchiftmnD?= =?us-ascii?Q?RgzL35UMuYvQXkZCt6tlDUP1tKi909xMxlq7n3Jt0VbyLlQSOVhabPRWMA6b?= =?us-ascii?Q?9HJOP3bj3/aG6RH2Q05SyInwMUNEblWNkrPJu2uGQ+M2AcySfG4jW6yMdQb3?= =?us-ascii?Q?bH+eLrwJvskGlEJ7wyLeNCOFQ4M?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1446;5:R5D/H7mNB6bJlg0ZFzYv/mLjn8MWZ66EhZxA9XKXbrDRfEpakZVzdkB+/+uKVnY8TmtFcFcZevV47BHfQ+iki2KCCKG6O8AEVWZQ8XwTmh/E6nrJmXVsD0mvD/zMc82C7bGrSCb7cLu7d9QM4PpYBw==;24:KAsNfS0mn9hT32Bw0RA5r4ZZjwkWfdfWYiC5QOhqBwcsIxDiQ6f4YaY32im5SjCt7eclZXDk95Yk0lddl9QHdFb9Kgi1DwFMUKUG2aH1aqE= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2015 22:48:04.1728 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1446 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2388 Lines: 83 Destroy mc_io in error path in dprc_probe() only if the mc_io was created in this function. Signed-off-by: J. German Rivera --- CHANGE HISTORY Changes in v3: none Changes in v2: - Addressed comment from Dan Carpenter: * Renamed goto error labels to indicate what the goto does drivers/staging/fsl-mc/bus/dprc-driver.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index 6d83035..cfbd779 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -401,6 +401,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) size_t region_size; struct device *parent_dev = mc_dev->dev.parent; struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); + bool mc_io_created = false; bool msi_domain_set = false; if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0)) @@ -413,6 +414,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) /* * This is a child DPRC: */ + if (WARN_ON(parent_dev->bus != &fsl_mc_bus_type)) + return -EINVAL; + if (WARN_ON(mc_dev->obj_desc.region_count == 0)) return -EINVAL; @@ -427,6 +431,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) &mc_dev->mc_io); if (error < 0) return error; + + mc_io_created = true; + /* * Inherit parent MSI domain: */ @@ -457,7 +464,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) &mc_dev->mc_handle); if (error < 0) { dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error); - goto error_cleanup_mc_io; + goto error_cleanup_msi_domain; } mutex_init(&mc_bus->scan_mutex); @@ -475,11 +482,15 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) error_cleanup_open: (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); -error_cleanup_mc_io: +error_cleanup_msi_domain: if (msi_domain_set) dev_set_msi_domain(&mc_dev->dev, NULL); - fsl_destroy_mc_io(mc_dev->mc_io); + if (mc_io_created) { + fsl_destroy_mc_io(mc_dev->mc_io); + mc_dev->mc_io = NULL; + } + return error; } -- 2.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/