From patchwork Tue Jul 28 02:14:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radha Mohan X-Patchwork-Id: 6879081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A951C9F38B for ; Tue, 28 Jul 2015 02:17:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D36DA20713 for ; Tue, 28 Jul 2015 02:17:16 +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 164BA206D0 for ; Tue, 28 Jul 2015 02:17:16 +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 1ZJuQe-00047D-A4; Tue, 28 Jul 2015 02:15:40 +0000 Received: from mail-ig0-x231.google.com ([2607:f8b0:4001:c05::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZJuQI-0002YW-0d for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2015 02:15:19 +0000 Received: by igr7 with SMTP id 7so97853597igr.0 for ; Mon, 27 Jul 2015 19:14:56 -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=D38zdF42dKk+YemFfocUmivixwWL3xdNLepH3tMp3RE=; b=aljqMCSPWXoJhGl+6F4n60SltSSfej8pIpOVKvptxinfMTMCA+TaoTBUYqRcsw4syb 4pHIlm0+MhylzXll6OD+GQ1giUQKiSnt0dDWaGK06NOMYZdZu8j11GD6KfkDQvlC85ot 3o/H7TmtSBLzTmmWauKkjOWgyvUk7MEk3wgWlSNEfGeyhHX5MfOsqAqSPes9q7aKGmou FnEguSEr2YN/PLOxAjD8ZbxilxRsCn5N9U1Z/+X/0TbndP3bTZ1nPzVo8jJ5vwHU4hug ehY+ImPVL8d9vr8FDXQq8xceJFNTXHrRo/GAGVfiQx8s6Wy/KXaZ2LSuypsbFVy2pmmW XH2Q== X-Received: by 10.107.164.38 with SMTP id n38mr48186858ioe.73.1438049696847; Mon, 27 Jul 2015 19:14:56 -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 191sm13323337iof.18.2015.07.27.19.14.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jul 2015 19:14:56 -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 2/3] net: mdio-octeon: Fix octeon_mdiobus_probe function for return values Date: Mon, 27 Jul 2015 19:14:42 -0700 Message-Id: <1438049683-10630-3-git-send-email-mohun106@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1438049683-10630-1-git-send-email-mohun106@gmail.com> References: <1438049683-10630-1-git-send-email-mohun106@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150727_191518_166091_1EB85310 X-CRM114-Status: GOOD ( 13.09 ) X-Spam-Score: -2.5 (--) 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: Radha Mohan Chintakuntla , Tomasz Nowicki 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.4 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 507aade..428ae75 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;