From patchwork Mon Mar 11 07:01:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10846821 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 546C21390 for ; Mon, 11 Mar 2019 07:01:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C62528E1E for ; Mon, 11 Mar 2019 07:01:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A74C28E40; Mon, 11 Mar 2019 07:01:48 +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 14CD028CC4 for ; Mon, 11 Mar 2019 07:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbfCKHBq (ORCPT ); Mon, 11 Mar 2019 03:01:46 -0400 Received: from mta-p8.oit.umn.edu ([134.84.196.208]:51998 "EHLO mta-p8.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbfCKHBq (ORCPT ); Mon, 11 Mar 2019 03:01:46 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 9C4009E9 for ; Mon, 11 Mar 2019 07:01:44 +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 LGnO9hUZjxdZ for ; Mon, 11 Mar 2019 02:01:44 -0500 (CDT) Received: from mail-it1-f198.google.com (mail-it1-f198.google.com [209.85.166.198]) (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 63F726F0 for ; Mon, 11 Mar 2019 02:01:44 -0500 (CDT) Received: by mail-it1-f198.google.com with SMTP id v12so4279062itv.9 for ; Mon, 11 Mar 2019 00:01:44 -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=KlxYLl9A5+lfbSkhTvNH/NPSfz6/FOooyJkl4ukt/HI=; b=pLBwS237v3GmbibpSvNDgYl9MJ+Mc3N9xHzn9ZSfExW3xYAhsnAM2pj/AaxN0zQf5M DgmRXiYB+EkBZlhwtiDLe1ePpVDqzayr37navfsjQ7TpbqmTcixT4Hzi4afQME8Aoi+Y oOWIxDSgUhKZY0Qnk8A7FDp6CjL3opI5pZmbG0LN3ChTm483atvY8yEjuXpKFPDW+5x0 y0vXwxS0ht6WPpgPTsKuzWXrSVX19V0jtDH+OYmqSE+q/60Fz1wWLK502CUM0VQHyoal nle4Yiawho6M8J8+Mp09ZB+U2xUEIjlL5RoxtkapGXc+EmO6+XriW+VxndUD3UM+tlGA PbDw== 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=KlxYLl9A5+lfbSkhTvNH/NPSfz6/FOooyJkl4ukt/HI=; b=kFk2bV7Y5JxQFGDGVd95fp9YrPEUDgs8XFEmRKlPXDbwO2TwReJL5L8LdhSQY56d1T 5KKWi2O3n+kduD9wRzYimvX5U/wG9ms2RsORbs2V7yj8/CZk280ef1yyKVHcefinbLry t1TwvoGvf7eyga0GfzQn3rUEB16c2CZgqVua0x9gyjj3KQekTHm9Av9nxZJ6CITlBSYM lrYv1A/9IOc7Btfzd6STdRhZmG4NOql+XV7Y0rN9mZ3Hf7Mn445UYGXXISTAdG2EiCnF ePZUR5krG3Y4sgw1vmQCtAVl8JiVqJ3X7H1ZZKzuzZyRynQ8Qz8saVq9He5qeY3z8tb0 zrvA== X-Gm-Message-State: APjAAAU3rndwBVOrR2HqCFwuEysNmkB3I45hb1sLwtb2Lam7l5NZES0w 6/g2drFs451382GNE+Wt10UuzPzv0BQhP8btNlVu8AareWPji6QRMiviUn8qczocVYsZMfdUPnm vP+5pZTjw4c3RaEMOqP3xIORhiEZci7Re16Y= X-Received: by 2002:a6b:7b08:: with SMTP id l8mr4044006iop.33.1552287703998; Mon, 11 Mar 2019 00:01:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoDxgrixltTM9JSqenvK/ZXS61q3HNAGzXHJC3KNsYgG5nhMY2tKYLyjwgh0RsRcE4NBBdEA== X-Received: by 2002:a6b:7b08:: with SMTP id l8mr4043993iop.33.1552287703775; Mon, 11 Mar 2019 00:01:43 -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 e10sm1283881iok.85.2019.03.11.00.01.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 00:01:42 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Sergei Shtylyov , "David S. Miller" , Vladimir Zapolskiy , Geert Uytterhoeven , Vladimir Barinov , Chris Brandt , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: renesas: fix a potential NULL pointer dereference Date: Mon, 11 Mar 2019 02:01:36 -0500 Message-Id: <20190311070138.24084-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 In case of_get_phy_mode fails, the fix returns NULL to avoid the NULL pointer dereference. Signed-off-by: Kangjie Lu --- 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..b119587ec673 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 (unlikely(!pdata->phy_interface)) + return NULL; mac_addr = of_get_mac_address(np); if (mac_addr)