Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753420AbcLNRrq (ORCPT ); Wed, 14 Dec 2016 12:47:46 -0500 Received: from mail-bn3nam01on0074.outbound.protection.outlook.com ([104.47.33.74]:56320 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751713AbcLNRro (ORCPT ); Wed, 14 Dec 2016 12:47:44 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@cavium.com; Subject: Re: [v2] net:ethernet:cavium:octeon:octeon_mgmt: Handle return NULL error from devm_ioremap To: Arvind Yadav , , , References: <1481732732-6892-1-git-send-email-arvind.yadav.cs@gmail.com> CC: , From: David Daney Message-ID: <3c3d5968-bc41-e1b7-6fda-78e92e7a9d56@caviumnetworks.com> Date: Wed, 14 Dec 2016 09:32:46 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1481732732-6892-1-git-send-email-arvind.yadav.cs@gmail.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: DM2PR07CA0036.namprd07.prod.outlook.com (10.141.52.164) To SN1PR07MB2143.namprd07.prod.outlook.com (10.164.47.13) X-MS-Office365-Filtering-Correlation-Id: 26087412-63d4-4c95-6c43-08d424473a45 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2143; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2143;3:L1DN1oeZbcw/xo1GdLPWQIMkp/ls4w6/6Y7efk1PnAd2KVGrgdDTB1cpWe/ClXC8QYgJzVKVlDkffMHE3zb8Mg4FJ8XwewTFdEU/TQCNjNefAy7WtbYFoZ/OpXkXrpEyn1lICnC8fV5pY6hlK8o4RNjfKRIisgNP24jQ51j5/NHxIqCm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K59D6+rDzmtPyC6HsPjOVtYe4dzrkNCwdrwppgmTooOgJo+775XinW8yLPTd1uY+p5uDeYweF6Cy4ngm++JrdfgYbJCKIf8IMMfnLHE2ls4v4YY12Ssp+tgAOKCl4QZKPvYETSPoUyhD4wvtWh+yniChSHHNnUC/xXjm;20:oYSaoud+vKkpkXBwljEp+UziaXsOTlImOhZ57YAaFyO0XoglSBtJbUgtd2b5+DYq+r1XuZszLgBlrN6RauqdB/TLuvchjfAdM/MnsJGWq5H1l9A2fdYtrW+b2ULrTn0uNwjdULofG5gRGZ6nfPhCUv4ev5DcvjBOL69Ls3Jv52d11N3QOhbjDV4/xjoa8LA/eXICkKCD4MkuuyX+PeeKqn3wcG3tKLQO5CTpRjSYrKWEmEjUDkFvoNeRwqmxerSOgL6XM99UTJbYq9SkIL3GXQ2DHkednfGv4tLngK+kIERabZ5I8EZ0cQwMNK64oEb387J7vE++F5/MCSXqRJeXgnG20myTU68G4PaqvsWz+r4mpDaGhpt5MpqwV02iYscyaNtANyB0YKTj5vhedx/gRqxjP9B3mapWFdg0/dwgx5Fh+TKH7xpvF8fEl/KEc9I9/GoTzAB7kfhxzIxvVGMbGwOI++evns59sSK1Dlcx/aVm9YDXYSjFOfTSq4QhYugVJotpDT8rmb5xWzvsKnGw0mbeA/Bn1eUnsk+06/GyADBV5FPkxnH8hx+liolwGvw84154L1Vlil95ms7aWsq3a4cUjUIg106EjkqGpsTxy4E= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123555025)(20161123562025)(20161123560025)(6072148);SRVR:SN1PR07MB2143;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB2143; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2143;4:bGgYpsIPhCwnsTiCKjvP84M8rE1dT6k0827F1BazhzYaxBln8cQ0L/j8sEuG/arTEctVyR5Mfh6Yb2Tobk2nyhealFcV0IESAW0xkgZyb0h4At0dCO4vLP9iVkjMkctf2dA+OyN/WoM2x0bQzSlTU/HH8ffY9VHn8nQ076PRDw5IyXMJvF61jOORYbCxpWI07LQbTb6n+2Kc0dU08stjK8yplZWU5Gv3ovLpNsix9yMcOOjnTn/dnupdvJ4hUmXk5LUJXQmHBi3C9CGArpLHqN6XkMxZnqGQ/rObhRiSvdGFcLxYgPCKCa9iAy5zPv9HNjgjDjktQjZGq7gViOxF23hZufPWofvG+4ky1feIOsR56jX39zAj+QYveqOWDpwSunA4bVJOLYnvzfeoxiFyiMSDhDLMj8X+BZMPudMeATi6meRo6iBH4EvRaoUdAaZUGSLoMRKfXfaeRSfMFOVQRhmXVWsxo+kpIy+I7HMNLSLH/uh8mBrxT9bOEcM+h9fgSRPFXSG3T5VM3VFEFloXLUn5qJt2pwv9bY5dfNiXnqSlrMni2WUEZisrMu6LQhX/ X-Forefront-PRVS: 01565FED4C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39840400002)(24454002)(377454003)(189002)(66684002)(199003)(53416004)(6506006)(230700001)(105586002)(54356999)(42186005)(31686004)(76176999)(6486002)(50986999)(39060400001)(5001770100001)(38730400001)(7736002)(97736004)(106356001)(42882006)(2950100002)(6666003)(4001350100001)(3846002)(4326007)(25786008)(6116002)(23746002)(68736007)(101416001)(229853002)(81156014)(81166006)(6862003)(64126003)(305945005)(8676002)(33646002)(50466002)(69596002)(189998001)(36756003)(66066001)(65806001)(65956001)(2906002)(65826007)(2201001)(8666005)(47776003)(92566002)(31696002)(6512006)(83506001)(5660300001)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB2143;H:ddl.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;SN1PR07MB2143;23:5OAFjyYmNvS/lhPH1M50Z3yU3aNnYR+rhMtO/?= =?Windows-1252?Q?33IIRKVfb46RzFquiY61zyiDQnDxLRdxMwUJASoJomOnKZpLrZlpRXa3?= =?Windows-1252?Q?X/LkG5vKXh0LBvYQX5X3+cF1xz/rf4VqR3mMihzUE4if/wtmn4Sqtq/4?= =?Windows-1252?Q?uvvWgKhESeDBFJoyh0WIAPSY4WUVyQMpv546bkPbazgWS2Z2Hwfu1WMj?= =?Windows-1252?Q?G1C+ZE7XmAVbMJy4MlXcFjNIC5sdwHm5pF+nNqEqlbzqqwH6qXXtvR7R?= =?Windows-1252?Q?k2eb0MKGjyu7ogwyN6jQw69Jh8djCE2S9nCBxzjZt3pJ92PnYZajgVx4?= =?Windows-1252?Q?WWpwAsdnHaZ8I3cX9rV+7MjRiugRtuzuof/fsRqr7UZa06I7pIXNRSqh?= =?Windows-1252?Q?VOM7gGXG2mmWaduWNM2tYTVFBzUnlGvrv6OsHhVcnF+zWY9p3ZLBnoao?= =?Windows-1252?Q?HHHchyI19TF4okZ3ZD2D2VPTh5++z4Dw6B2Zz+zIShVe+Ude3rOXkSbe?= =?Windows-1252?Q?Hy5WbcXZZD++ptB1cfMH4WoCf/g3hXcAPMTYphT2KMFQfmM5xVTFEpC+?= =?Windows-1252?Q?A/Nio8nevKzsAw0N6PeLE8nPdPVXrD27Q/mmu1TkTHoaleK+2rOZL8yc?= =?Windows-1252?Q?o9ntBHC6JUlhnc9a9hnVTb5D6oJHeuqsB90eSkCLHkujC+6b3kq/PxtG?= =?Windows-1252?Q?MbT+tOsYULOtzPaIev0bRi3LQHS/zkFa6/9pw+1lgdzHSIbaqT/P0hGI?= =?Windows-1252?Q?oRy7NnCqqOZEiexRt4y9NREwm2qAh3VU26lV+pCI6RR8dpjVIt81XLcm?= =?Windows-1252?Q?qlAMg0wNubqdqYVjpz//CsudlQXSTxgWvjeFi124oAksCsaMsBcuNxHC?= =?Windows-1252?Q?X2Q1+KaTITf4ORiyfgBRrqIJQLfPHmQZQjcA+2ymYTg3UVsbEYDkR5hU?= =?Windows-1252?Q?rWVGaLOP5b3immywJD2UWZR8rLh0rzXGd1pUGcKCNnDAgiCBPKKmAob/?= =?Windows-1252?Q?7s7ZyvkqEdR8ehsb1//Z9pZbQKuzyBeCOzvBL07LWmAB65GHeIY0aQep?= =?Windows-1252?Q?NCY58AEZ3m4wpbBwCWbioNe/+JoQUF0JEb+zeuGl06tMwQJMYlSgQbmA?= =?Windows-1252?Q?wYEXnpcCaPGjT4dLXVg+IJeU/mAN+lHaiiyaVqC+r95HGRw2Lj8hs5zo?= =?Windows-1252?Q?HXMDhh1iQIsm78WZPzcuOacANEJHmMNHyOBIw/mUlO+s++mycO8UtVOa?= =?Windows-1252?Q?jr8XwwSNbW0O27pG8QGaR2qozLXznBEDQzdEeurFL8G6PVQB7+vt/zbb?= =?Windows-1252?Q?aBuq5c9gFm9xX7gLRofIYtBMk6Xvq8EquTdaL04pt/9aKLSlmDCXcVqU?= =?Windows-1252?Q?ORQE7kEKHWRsqVEWyVpRQeuufwE+akySTzQraxdkL9NOOuuV20INbT0t?= =?Windows-1252?Q?BRSZVNi/0ZZlxF9sHD9bzn7/f+OLKrbDE8R5KVj4YElBStElxkK/+QbO?= =?Windows-1252?Q?LrxdMLVz1Wh+qxhdRCHitocS+hHC2STcBEnT3UadtQoR+MIUn7yQJjwI?= =?Windows-1252?Q?aMPd6WUuJKG8hdG/+9IASs1EvDocp0H1BxnFPJD/N0rnYszol/xdhBxj?= =?Windows-1252?Q?dfBqbOHBMIHtVCVtq8ZvF38oT+sbMKfYVfX3OzxCIrr?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2143;6:BZiTHDaK4H/aYVzARijdn6s+5Gos1seoMQEFXL3LXbP9p1ILvMjgfIV6XSwSe7nCcv1TC6DqPKSsxNHxhYdC3gfejGUFsGhp6/2T8S/jcK4GKzn7DRL/dmQSqFhz7D3K+oC8IPYnS0muWMsWfJlyvY490TTSkZ80VJZsbv2hDXyDm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qkQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2016 17:32:49.8893 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2143 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1213 Lines: 37 On 12/14/2016 08:25 AM, Arvind Yadav wrote: > Here, If devm_ioremap will fail. It will return NULL. > Kernel can run into a NULL-pointer dereference. > This error check will avoid NULL pointer dereference. > Have you ever seen this failure in the wild? How was the patch tested? Thanks, David Daney > Signed-off-by: Arvind Yadav > --- > drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c > index 4ab404f..33c2fec 100644 > --- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c > +++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c > @@ -1479,6 +1479,12 @@ static int octeon_mgmt_probe(struct platform_device *pdev) > p->agl = (u64)devm_ioremap(&pdev->dev, p->agl_phys, p->agl_size); > p->agl_prt_ctl = (u64)devm_ioremap(&pdev->dev, p->agl_prt_ctl_phys, > p->agl_prt_ctl_size); > + if (!p->mix || !p->agl || !p->agl_prt_ctl) { > + dev_err(&pdev->dev, "failed to map I/O memory\n"); > + result = -ENOMEM; > + goto err; > + } > + > spin_lock_init(&p->lock); > > skb_queue_head_init(&p->tx_list); >