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: 3116231 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C5E29F2B7 for ; Wed, 30 Oct 2013 19:30:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D4F220426 for ; Wed, 30 Oct 2013 19:30:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 724672041D for ; Wed, 30 Oct 2013 19:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754598Ab3J3TaZ (ORCPT ); Wed, 30 Oct 2013 15:30:25 -0400 Received: from mail-lb0-f170.google.com ([209.85.217.170]:58561 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754286Ab3J3TaW (ORCPT ); Wed, 30 Oct 2013 15:30:22 -0400 Received: by mail-lb0-f170.google.com with SMTP id u14so1619900lbd.15 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=WoqMgQE2lX6PGKHG0LLEQnbJsIBtZI5oNJ8MLmYwoQhziYQ1rGnauKEfoBLqF4Sle+ TNMf2r8pVHluLkBJJDVRUbFstZWTgxlG/X2hngMDJJtY5+bU7IUO4a9LJ6Cfb/PmqHOF Rl/sMYgQaKnHlA2sJOYyTeolcC6yyH1MXaKGUYpcSQppoGepZe0NtkeeRyDUQfVfIFX+ M+TDj/bboVIhFgALeR8bqaaqBmLGK0ViQvaCxIOmkPezVej19bG4QUTGbYZjnOMTZ7Oe CW5ACQBOq0CifN/aQvPh8jL5UUVgrsiis97l0UX9pmsO+3C9MIXL0d2yc79w+QBQMZFA miZA== X-Gm-Message-State: ALoCoQliIUY1X+MRn5EfDL4jyfvrE7A3wlImxhG2XhSwdjysRnQHv/7E2P+PL5xMSDO9suHp9KuA 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: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 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 linux-sh" 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;