From patchwork Tue Jul 28 22:12:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radha Mohan X-Patchwork-Id: 6888671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 484F5C05AC for ; Tue, 28 Jul 2015 22:15:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F1D620749 for ; Tue, 28 Jul 2015 22:15:34 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 29A002073C for ; Tue, 28 Jul 2015 22:15:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKD7m-0005ie-59; Tue, 28 Jul 2015 22:13:26 +0000 Received: from mail-io0-x242.google.com ([2607:f8b0:4001:c06::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKD79-0005Pp-UD for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2015 22:12:49 +0000 Received: by iojj196 with SMTP id j196so86533ioj.1 for ; Tue, 28 Jul 2015 15:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YJ5rlL9a7CjocR6r4MOb0oJotakPXH0v9zQBk3uWpMc=; b=sJ7m2cT26NzoyZzTmXBw8O0CKXxuBZzaF7+wpHMIEZYNCjGqQbE/rBI6FWYfzEZA70 tqSneT57O2zxD++VVUeKKLLkEOnytv2Xzvo9VbZAq/a8pI861RW4UwBpJspdbClgh6r6 /yT9kRp1thCLNAhRJIjEW63iQqMhqdd/JAgwJ+WoMzf6qYfRvBM+aNe3bmImVh1skjaZ c1TBDRHABdD34GJXSeW0Az3uUF9vC543KfehpLHwFcHYbUpsh0+IPUo0WW8JCZCuVwy4 cxwRrT/1A2AWLfCKtbnOQsyuQNT/PaF0nRcnfobIyKR2eFOQrl344UfIM1piguRTrjDk mEIw== X-Received: by 10.107.132.157 with SMTP id o29mr55253321ioi.104.1438121547018; Tue, 28 Jul 2015 15:12:27 -0700 (PDT) Received: from localhost.localdomain (64.2.3.194.ptr.us.xo.net. [64.2.3.194]) by smtp.gmail.com with ESMTPSA id f126sm15432227ioe.21.2015.07.28.15.12.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jul 2015 15:12:26 -0700 (PDT) From: mohun106@gmail.com To: f.fainelli@gmail.com, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] net: mdio-octeon: Fix octeon_mdiobus_probe function for return values Date: Tue, 28 Jul 2015 15:12:12 -0700 Message-Id: <1438121533-21528-3-git-send-email-mohun106@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1438121533-21528-1-git-send-email-mohun106@gmail.com> References: <1438121533-21528-1-git-send-email-mohun106@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150728_151248_108464_99262907 X-CRM114-Status: GOOD ( 13.58 ) X-Spam-Score: -1.8 (-) 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: Tomasz Nowicki , Radha Mohan Chintakuntla , ddaney@caviumnetworks.com, sgoutham@caviumnetworks.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Radha Mohan Chintakuntla This patch fixes a possible crash in the octeon_mdiobus_probe function if the return values are not handled properly. Signed-off-by: Radha Mohan Chintakuntla Signed-off-by: Tomasz Nowicki --- drivers/net/phy/mdio-octeon.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c index 1509937..fcf4e4d 100644 --- a/drivers/net/phy/mdio-octeon.c +++ b/drivers/net/phy/mdio-octeon.c @@ -277,24 +277,28 @@ static int octeon_mdiobus_probe(struct platform_device *pdev) return -ENOMEM; res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res_mem == NULL) { dev_err(&pdev->dev, "found no memory resource\n"); - err = -ENXIO; - goto fail; + return -ENXIO; } + bus->mdio_phys = res_mem->start; bus->regsize = resource_size(res_mem); + if (!devm_request_mem_region(&pdev->dev, bus->mdio_phys, bus->regsize, res_mem->name)) { dev_err(&pdev->dev, "request_mem_region failed\n"); - goto fail; + return -ENXIO; } + bus->register_base = (u64)devm_ioremap(&pdev->dev, bus->mdio_phys, bus->regsize); + if (!bus->register_base) { + dev_err(&pdev->dev, "dev_ioremap failed\n"); + return -ENOMEM; + } bus->mii_bus = mdiobus_alloc(); - if (!bus->mii_bus) goto fail;