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: 2852273 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 3F6249F495 for ; Sat, 31 Aug 2013 00:23:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 62EB320453 for ; Sat, 31 Aug 2013 00:23:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8256820448 for ; Sat, 31 Aug 2013 00:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753553Ab3HaAX3 (ORCPT ); Fri, 30 Aug 2013 20:23:29 -0400 Received: from mail-lb0-f179.google.com ([209.85.217.179]:62074 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752991Ab3HaAX2 (ORCPT ); Fri, 30 Aug 2013 20:23:28 -0400 Received: by mail-lb0-f179.google.com with SMTP id x18so2388273lbi.38 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=f3jpX4I/JGSY/EVUOK4DfMvAgXmLN9Kj8TftVpw/ChP4DIX6QZipwiJSW4BUZeirE2 dpZwKdpyyEO9axIG2yMft8cR0AyzNW/zFbRDqVHg6oKVD7VT+j2DkIQY+EoRZgEuSG2/ Gafm5z+mjxQ4NmkfwQnpKynwdcfMnYu2FVI6/jcyhcT5kXgGQEbh1s2gQBHv20yLJVqI nSre4wUuOavagICUSOnYTpbnQkdMqjQQIwiy6/Kru7Tj3z7RGPbne6p8g8jQ3Nivi23k +ezGomSLvud6pW9i/5Wkv60s6Wz32AHaA/M3JVX7EsMUQQOuz1T3lAbDQaUP89OOa1b7 IjEg== X-Gm-Message-State: ALoCoQlXOZWrNKKuUzjWhccNWj7sAqZWJ+rL5VIQEMG1sr5W/FlU5ut9xSp9RQFfwvQqUkDnYx9z 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: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-9.0 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 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 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 @@ -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;