From patchwork Tue Mar 12 06:30:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10848611 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 080391575 for ; Tue, 12 Mar 2019 06:33:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E592029489 for ; Tue, 12 Mar 2019 06:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8F552948F; Tue, 12 Mar 2019 06:33:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F79D29489 for ; Tue, 12 Mar 2019 06:33:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbfCLGdL (ORCPT ); Tue, 12 Mar 2019 02:33:11 -0400 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:37904 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbfCLGdL (ORCPT ); Tue, 12 Mar 2019 02:33:11 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id 6A0B898E for ; Tue, 12 Mar 2019 06:33:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zD83r-Fn28Bv for ; Tue, 12 Mar 2019 01:33:09 -0500 (CDT) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id 423839A8 for ; Tue, 12 Mar 2019 01:33:09 -0500 (CDT) Received: by mail-io1-f70.google.com with SMTP id n23so1070636ioj.10 for ; Mon, 11 Mar 2019 23:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ha9PW7pIPJPn/3E35z3kTO9/Th37iu1RWxZGXsOeCtg=; b=jWGw53lZcMw7+b3WK4goiihsxr7OqN+Auv/UvXG/K13EIP5f+cOiWxsUEq9odYb4M2 XvOEGEZToOxyZhhTCIiHEJkYRNPDizZEIw6fu7SN4ZcGB3NeDUtWm4wqo0hpeGIKKyPb YRxDp1zrrnS2B3eFlYq5RKun/Ijmhm9i0AFo5E8zUTrlJSKDgMs+lSqoAvBqBU/Xh0vH IzSD2DlaoZZ2diMf1Cyca/zr0ryO3CBNuoUEuz9X+Mk2QUs5d/vhJPCV3u4WBj0AvMr3 CigBfr54gBncNW0yhoTirEKoHvZlyy5ZGFe6MB1ETmam2r3HUvPfGH1twc+iZqN9M7k8 bSww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ha9PW7pIPJPn/3E35z3kTO9/Th37iu1RWxZGXsOeCtg=; b=Lb91L2zMWJqeoVekar2deh7Ibi1cwH4zYq6hmZmO2ui/peSvYx5DqTA2dGct4IPvyM TRaFa3Ue7wlSArruJ8oP1ygUKgRcJs2YmSxHvEZMh0iPVvbuDuIUHcVKQq4azojFie1y RcRzchIl3FEnOfTA1HjPffxgnrZpp9eT4dGiAHUze/LKuu018uBhG1em3g88nTwRvZFT BGRWM6Uunkbby5LSigq2woJ49HBSRSs8CIgA79YvKu92xFkVI74o9M6FPqWqhfHPnBIh RjqLyM7xhd3XbH6DWvurK3FVeO+QLSkwJQnD7tN/b0M4S3cNRIvxBSJAQVdlXCb+DPFF elew== X-Gm-Message-State: APjAAAVcLpKZe7ivwAZAn3HKCwaDmb2ne+xzZ9eA+Xl1Sv73bn5x0hV4 +/PXzO8D63feHfGus+ODMGCZYo9u34pqDrtEbRDsg3Wwfg5TJkt7L29+0ZyuXIC25O1TlMuqEdU +z8CuL8+QScnIxfIy+h+d73BJQ2nXIAU3iOs= X-Received: by 2002:a6b:ea19:: with SMTP id m25mr9689471ioc.291.1552372388769; Mon, 11 Mar 2019 23:33:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJKL43alLWjqG0b6skYN7rnA1g31yJYG8Wi9Bu3Xc6MwUOEVw6D/gxFoQ0Q+dN5gP/rfYZEQ== X-Received: by 2002:a6b:ea19:: with SMTP id m25mr9689450ioc.291.1552372388470; Mon, 11 Mar 2019 23:33:08 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id p18sm897264itp.10.2019.03.11.23.33.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 23:33:07 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Sergei Shtylyov , "David S. Miller" , Vladimir Zapolskiy , Geert Uytterhoeven , Chris Brandt , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: sh_eth: fix a missing check of of_get_phy_mode Date: Tue, 12 Mar 2019 01:30:24 -0500 Message-Id: <20190312063026.15083-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_get_phy_mode may fail and return a negative error code; the fix checks the return value of of_get_phy_mode and returns NULL of it fails. Signed-off-by: Kangjie Lu --- drivers/net/ethernet/renesas/sh_eth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 239eeafe1b2d..e33af371b169 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -3181,14 +3181,16 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) struct device_node *np = dev->of_node; struct sh_eth_plat_data *pdata; const char *mac_addr; + int ret; pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; - pdata->phy_interface = of_get_phy_mode(np); - if (pdata->phy_interface < 0) + ret = of_get_phy_mode(np); + if (ret < 0) return NULL; + pdata->phy_interface = ret; mac_addr = of_get_mac_address(np); if (mac_addr)