From patchwork Tue Jan 28 14:04:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76B2CC33CB3 for ; Tue, 28 Jan 2020 14:44:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D92620716 for ; Tue, 28 Jan 2020 14:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222692; bh=cdS438oyPWqFatWtdHTGGlYeR61YSDdTm3C57FtzmrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CA+2dgiMAZKJvifZ+jxqPP6IkcWXDLLKweA+truj4B31wtAEvOiBKRbgZT+4GW3Bs eQXXnYZIwbg9xz2zZbUNWbdZxpL17b1plMS85qEc/169MDoMHOXWYfCMtfOb/5qXIj /KYeCK5r8IO/d5gBe1WPByBM4EcWXOqzgu05LESg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbgA1OJc (ORCPT ); Tue, 28 Jan 2020 09:09:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:57954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728884AbgA1OJc (ORCPT ); Tue, 28 Jan 2020 09:09:32 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6534F24690; Tue, 28 Jan 2020 14:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220571; bh=cdS438oyPWqFatWtdHTGGlYeR61YSDdTm3C57FtzmrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZsAJov1xJSIWtBf2ONRBREH5DDmrHGZgIA64fxt4Nl612fvSrBrpwXk9z74eu0xof qox2JTHw0gnP3GoZExuFMGnMcmjYqCUN0GLWUyqlpgvoW1UcGyR3bBneVokevQut4D G6Fx6dnB9pR5lg90LeFHLoZvQF+A28EW6aidyawU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Sergei Shtylyov , Geert Uytterhoeven , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 060/183] net: sh_eth: fix a missing check of of_get_phy_mode Date: Tue, 28 Jan 2020 15:04:39 +0100 Message-Id: <20200128135835.939492536@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135829.486060649@linuxfoundation.org> References: <20200128135829.486060649@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Kangjie Lu [ Upstream commit 035a14e71f27eefa50087963b94cbdb3580d08bf ] 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. Fixes: b356e978e92f ("sh_eth: add device tree support") Signed-off-by: Kangjie Lu Reviewed-by: Sergei Shtylyov Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/renesas/sh_eth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 2d9f4ed9a65ed..8413f93f5cd94 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -3040,12 +3040,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); + 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)