From patchwork Mon Jul 11 23:35:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 647146 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rpM1B2nq7z9s9n for ; Tue, 12 Jul 2016 09:36:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=ThyeacZR; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbcGKXgF (ORCPT ); Mon, 11 Jul 2016 19:36:05 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35962 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbcGKXgC (ORCPT ); Mon, 11 Jul 2016 19:36:02 -0400 Received: by mail-pf0-f196.google.com with SMTP id i123so14108580pfg.3 for ; Mon, 11 Jul 2016 16:36:01 -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=/9sJKmcLIA2K88Qj5xXKeMojyqhR5On9TukcTynd+10=; b=ThyeacZRiCDhFY1Oub7rHwfIBB4oOmu5pY6PITjEOyBcRN7ge+j5GTkH0wY6pHsKvy V7dLjcgucl8aYqJILp5quTdFQq5Ob1gVFGZL74VqpVYVa1Pe0eZFzIFozrcasZqjrjvE tMrAyDfiSwMkv+Y1K+sUPZFohKZg2C6W8hkAVr0/S6fPLCrhzUZsaXU4UGuSCG5qFUiN mbLcvjKfSjRD+4WEa9sARl21WJIHE9VcPGa+NnyFc42dhsfBt5Zl7onEAS7OmTEWrz5r YTRmJWmvlUsOPlwh4KkM4FpcH+my+aDJSL311vujbrrtIzUmQ8dtiqN+tjCNvIqpbUeB lhWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/9sJKmcLIA2K88Qj5xXKeMojyqhR5On9TukcTynd+10=; b=Q42NVDL7Tg/+7f5/TcnrRS+Zhtsq+Qxmh+03KLYyCjttj/beVjkMACRs6ispYDOll0 f/vRPThafWVgCkWlXDYQPDVad9ISUPzljJYZuhUoFiOcnSZH9708AzGe5upxnl608zuh i7mGgnxLI8eIHXPV2g0UDv+SC3tEF2jy4CMN/C6OKVSxAx+MUuKJXPN6x3D6S8iW98qd RETbFUYBT8HS8LbKmI0BCk1T+HsrwDfvi29aj8HzN6zriEsNdjnGz4lZLwIi/0sJjvR3 jKRQNU2tIihADFn5RMndE6sqBlNup12yM7KVg4MRF9V1cwEpYk73IqEpug2tZJN74C+j ybAg== X-Gm-Message-State: ALyK8tKUiHoaKT9i8MmanoKnx9ws+TXVxjlI9LAWyOCw0tQpA9gWKNfyBgrSC0cZnYewvA== X-Received: by 10.98.74.201 with SMTP id c70mr17849177pfj.113.1468280161158; Mon, 11 Jul 2016 16:36:01 -0700 (PDT) Received: from fainelli-desktop.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by smtp.gmail.com with ESMTPSA id xl1sm7398480pab.8.2016.07.11.16.35.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jul 2016 16:36:00 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: davem@davemloft.net, jcmvbkbc@gmail.com, colin.king@canonical.com, tklauser@distanz.ch, thierry.reding@gmail.com, Florian Fainelli Subject: [PATCH net v2 1/2] net: ethoc: Fix early error paths Date: Mon, 11 Jul 2016 16:35:54 -0700 Message-Id: <1468280155-13152-2-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468280155-13152-1-git-send-email-f.fainelli@gmail.com> References: <1468280155-13152-1-git-send-email-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In case any operation fails before we can successfully go the point where we would register a MDIO bus, we would be going to an error label which involves unregistering then freeing this yet to be created MDIO bus. Update all error paths to go to label free which is the only one valid until either the clock is enabled, or the MDIO bus is allocated and registered. This fixes kernel oops observed while trying to dereference the MDIO bus structure which is not yet allocated. Fixes: a1702857724f ("net: Add support for the OpenCores 10/100 Mbps Ethernet MAC.") Signed-off-by: Florian Fainelli --- drivers/net/ethernet/ethoc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 4edb98c3c6c7..06ae14a8e946 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c @@ -1086,7 +1086,7 @@ static int ethoc_probe(struct platform_device *pdev) if (!priv->iobase) { dev_err(&pdev->dev, "cannot remap I/O memory space\n"); ret = -ENXIO; - goto error; + goto free; } if (netdev->mem_end) { @@ -1095,7 +1095,7 @@ static int ethoc_probe(struct platform_device *pdev) if (!priv->membase) { dev_err(&pdev->dev, "cannot remap memory space\n"); ret = -ENXIO; - goto error; + goto free; } } else { /* Allocate buffer memory */ @@ -1106,7 +1106,7 @@ static int ethoc_probe(struct platform_device *pdev) dev_err(&pdev->dev, "cannot allocate %dB buffer\n", buffer_size); ret = -ENOMEM; - goto error; + goto free; } netdev->mem_end = netdev->mem_start + buffer_size; priv->dma_alloc = buffer_size; @@ -1120,7 +1120,7 @@ static int ethoc_probe(struct platform_device *pdev) 128, (netdev->mem_end - netdev->mem_start + 1) / ETHOC_BUFSIZ); if (num_bd < 4) { ret = -ENODEV; - goto error; + goto free; } priv->num_bd = num_bd; /* num_tx must be a power of two */ @@ -1133,7 +1133,7 @@ static int ethoc_probe(struct platform_device *pdev) priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL); if (!priv->vma) { ret = -ENOMEM; - goto error; + goto free; } /* Allow the platform setup code to pass in a MAC address. */