From patchwork Sat Aug 31 00:23:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 271492 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 35B572C00C6 for ; Sat, 31 Aug 2013 10:23:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754021Ab3HaAX3 (ORCPT ); Fri, 30 Aug 2013 20:23:29 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:56025 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752996Ab3HaAX2 (ORCPT ); Fri, 30 Aug 2013 20:23:28 -0400 Received: by mail-lb0-f169.google.com with SMTP id z5so1732789lbh.28 for ; Fri, 30 Aug 2013 17:23:27 -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=iBzWRuUwYdQjkEYavPRfO7H8A6RXzE+02dLr4U1hm0E=; b=ADc1N4X+KWXrQw/8lKil2bsfsXB1rFDjRFZQSDeBB03ap/8CcpRh5N+0RSgUaA0og+ YDISOkZ8iojh4Ln8MQAHKIy2ggkyHUgXbtQv9GpHDFuszvx67NFmzh2h/VseMACk45y/ l9myW8zyRaiCVUZLGjNFCknrUdopzc+URq3isqXQsse0u31JtJ9GiFuBPk5YXvz8YraP A/Nzi2VUs/TLatl4NvhBxQdsD2E+c49G0IPW2Ojmj2T+p9UDwoYdrlJp6fuq4brLENmA KgnNs7UoijbTmkFzKlMdwpGAzcqq2c64weJl0y+GMh9s8QX6vTsh7YL1vmjDdofB+YOP K4qg== X-Gm-Message-State: ALoCoQlN0Q2C7w+oTzgEOoV0295EhPdmzup0F+RR+nIxSaddu45rMNIx5wRxMhYQmWF+ZhFDX/5r X-Received: by 10.112.57.49 with SMTP id f17mr10023237lbq.26.1377908607141; Fri, 30 Aug 2013 17:23:27 -0700 (PDT) Received: from wasted.dev.rtsoft.ru (ppp91-76-94-226.pppoe.mtu-net.ru. [91.76.94.226]) by mx.google.com with ESMTPSA id ap7sm206290lac.10.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 30 Aug 2013 17:23:26 -0700 (PDT) To: netdev@vger.kernel.org Subject: [PATCH 1/2] sh_eth: check platform data pointer Cc: nobuhiro.iwamatsu.yj@renesas.com, linux-sh@vger.kernel.org From: Sergei Shtylyov Organization: Cogent Embedded Date: Sat, 31 Aug 2013 04:23:29 +0400 MIME-Version: 1.0 Message-Id: <201308310423.30322.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 Reviewed-by: Simon Horman --- This patch is against Dave's 'net-next.git' repo. 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 @@ -2653,6 +2653,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;