From patchwork Wed Oct 30 20:30:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 287331 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 35A7F2C0361 for ; Thu, 31 Oct 2013 06:30:32 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754608Ab3J3TaZ (ORCPT ); Wed, 30 Oct 2013 15:30:25 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:47359 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754369Ab3J3TaW (ORCPT ); Wed, 30 Oct 2013 15:30:22 -0400 Received: by mail-lb0-f180.google.com with SMTP id y6so1574493lbh.25 for ; Wed, 30 Oct 2013 12:30:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:cc:from:organization:date :mime-version:content-type:content-transfer-encoding:message-id; bh=+y/KIfk5vMm5CGqgh8iLvhXF1FpdBdRvqK9HkcjTxWA=; b=ACb6So238ud10EFos6qiSdMyoX6eeuBRbA1xIyMUdmJhJjNPyP4M+vvOg20ElKYXPT ttCpk+exSq+Y7mynxNwbgPbg4QTj4oaYYYenUJgAZUsKOIn8czfON+agbJlcze1YWP+k GJ/V029fgOabYwqRl87RzNzifZji0CLON0QnQ7WfNMiKpA2NyqC/SLzafPNpoqU5A6rP B01BMwJ1RgFVcSR3WLzOHooH30LMYenb0f2juSDJIn7+TV+f7VEp+fr83fYedz+JRDGe IYOd8jSewNE4TzE1eio613bqkBDTQttiukLjUMKVGJz+MHUu4LKJbEJgUyoAxqfVPLBp qV0A== X-Gm-Message-State: ALoCoQl2MQkrIayLK6PMj3SEHBPGJ59KbBC2j4PvZnS5pCIoy/GueFwO3D+ddMDrOz6/S1Gsc+kL X-Received: by 10.112.133.161 with SMTP id pd1mr39225lbb.82.1383161421036; Wed, 30 Oct 2013 12:30:21 -0700 (PDT) Received: from wasted.dev.rtsoft.ru (ppp83-237-58-97.pppoe.mtu-net.ru. [83.237.58.97]) by mx.google.com with ESMTPSA id sc4sm32264703lab.10.2013.10.30.12.30.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 30 Oct 2013 12:30:20 -0700 (PDT) To: netdev@vger.kernel.org Subject: [PATCH v3] sh_eth: check platform data pointer Cc: nobuhiro.iwamatsu.yj@renesas.com, linux-sh@vger.kernel.org From: Sergei Shtylyov Organization: Cogent Embedded Date: Wed, 30 Oct 2013 23:30:19 +0300 MIME-Version: 1.0 Message-Id: <201310302330.19491.sergei.shtylyov@cogentembedded.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Check the platform data pointer before dereferencing it and error out of the probe() method if it's NULL. This has additional effect of preventing kernel oops with outdated platform data containing zero PHY address instead (such as on SolutionEngine7710). Signed-off-by: Sergei Shtylyov Acked-by: Simon Horman --- This patch is against David Miller's 'net-next.git' repo. Changes in version 3: - refreshed the patch. Changes in version 2: - refreshed the patch. drivers/net/ethernet/renesas/sh_eth.c | 6 ++++++ 1 file changed, 6 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net-next/drivers/net/ethernet/renesas/sh_eth.c =================================================================== --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net-next/drivers/net/ethernet/renesas/sh_eth.c @@ -2663,6 +2663,12 @@ static int sh_eth_drv_probe(struct platf pm_runtime_enable(&pdev->dev); pm_runtime_resume(&pdev->dev); + if (!pd) { + dev_err(&pdev->dev, "no platform data\n"); + ret = -EINVAL; + goto out_release; + } + /* get PHY ID */ mdp->phy_id = pd->phy; mdp->phy_interface = pd->phy_interface;