From patchwork Mon Mar 11 07:49:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10846849 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 413CC18EC for ; Mon, 11 Mar 2019 07:50:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A57A289B7 for ; Mon, 11 Mar 2019 07:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1893D28DD9; Mon, 11 Mar 2019 07:50:04 +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 B2934289B7 for ; Mon, 11 Mar 2019 07:50:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbfCKHuD (ORCPT ); Mon, 11 Mar 2019 03:50:03 -0400 Received: from mta-p8.oit.umn.edu ([134.84.196.208]:58532 "EHLO mta-p8.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbfCKHuD (ORCPT ); Mon, 11 Mar 2019 03:50:03 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 8EF439D2 for ; Mon, 11 Mar 2019 07:50:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mP77XS0eu1MH for ; Mon, 11 Mar 2019 02:50:01 -0500 (CDT) Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id 5B4C79CB for ; Mon, 11 Mar 2019 02:50:01 -0500 (CDT) Received: by mail-it1-f200.google.com with SMTP id 142so4366223itx.0 for ; Mon, 11 Mar 2019 00:50:01 -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; bh=Ad+Ht6iuPEK3V66itIO25xm2d2MmiWnk2HmclFaUdgw=; b=VDNZtG59PFO7DSh0K1Jhd7J/P9sr1z5nGz5m24NANiVWhaC6/kijvsGQKeLD+9NTV/ RlsQoOio6SjU5DcZnFd5dqBdQYO1qDtjNDSHFVx6fZ4tZtElwS6uleVsLehsznLbEQiU Az/VaVelJECl2hvDUu34Sj3sUVD6AL5uHhi/FSaTvucmJ8LTU0nxG7SNKLh9aEGQqM+Q ErilQYuzOGronQY8OiIRExqvOvybK51e4xvuGMfAAC6FJjRaXk6J6APnVsZm9yZ9EjX6 KIOIJsRa+hkEhxsDzMBahiY5AoxjcL8VfYLhrcl7ZFG3I+AagOyewqzkEanrnA735PEQ 56AA== 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; bh=Ad+Ht6iuPEK3V66itIO25xm2d2MmiWnk2HmclFaUdgw=; b=njucyCFRpyjkOUEjYRiWwKTBatqUWapAEMaiWzQYFyyfW1f2KjpKK6lxSu4NHCcaVK /T2wBze/pkYH9t/oz5Xgr7/3Z6CiNGDaYUji7ppLppzqMZI0501Lhdo8irTX7hrO+I2l R0weesBOK4/OpCf9jyWRZWoyaFcC+dHz0ev7Y50X8xw4vgm31h9fnmViUfa++miXTJcr zH6Bir7aVoJ4SRX3eLrLndeMLDGjc5JSLmyHZTI/MztCHFPpAQpfmkuwjgCiBXGc9Hzw IpVXs/Zgp3FbjyOCTy5IIZO/cDhgSENtBPp22jklD1n18zpRAe37n8ml0RZap4gsOmY5 OGzQ== X-Gm-Message-State: APjAAAW1I6CaNz3+csld2G6Ta2En0S3u80GCIwwbLdD4VOrcds7rRWe3 zQgZsXHTNtej5a1ZI8RzJwJDedaTtsUFfWVyVfFcXahDW6KIu8uxflA2JNZy3RR6oaNLNz9h0v8 rU/qKXmcJAPxFmHya4ZgWmFB9tI9X61wbCRA= X-Received: by 2002:a24:1091:: with SMTP id 139mr15197827ity.110.1552290600968; Mon, 11 Mar 2019 00:50:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEcwbeVHeTUD0YZEey71JInwRH/jTEenqU6CZEUTD1zMNotqyC2OqmpD6lJpywuJsoIPrvZg== X-Received: by 2002:a24:1091:: with SMTP id 139mr15197810ity.110.1552290600647; Mon, 11 Mar 2019 00:50:00 -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 d6sm1852609ioc.44.2019.03.11.00.49.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 00:49:59 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Sergei Shtylyov , "David S. Miller" , Vladimir Zapolskiy , Geert Uytterhoeven , Simon Horman , Chris Brandt , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode Date: Mon, 11 Mar 2019 02:49:37 -0500 Message-Id: <20190311074939.517-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 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 Reviewed-by: Sergei Shtylyov --- drivers/net/ethernet/renesas/sh_eth.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 339b2eae2100..239eeafe1b2d 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -3187,6 +3187,8 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) return NULL; pdata->phy_interface = of_get_phy_mode(np); + if (pdata->phy_interface < 0) + return NULL; mac_addr = of_get_mac_address(np); if (mac_addr)