Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp460981ybl; Tue, 28 Jan 2020 06:19:54 -0800 (PST) X-Google-Smtp-Source: APXvYqyYEwxCpwlx7cL9XR69mF6adfjxS4e1+yplq3FqPTsxvokJvjLOg8pmwroFcIjHPT3a5mGn X-Received: by 2002:a9d:545:: with SMTP id 63mr1650909otw.285.1580221194070; Tue, 28 Jan 2020 06:19:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221194; cv=none; d=google.com; s=arc-20160816; b=hojm9pvpLV6zovuF5RiqtDCeLhwRkLCU9uxV3stnI7RqkTZt3uIwACYW5FQCe56h4Y /OGnllnnoIohXmNVBTQRwK+CONyQr+VU6OulVyeEgqFTencOG+1JUs4gQTwl/I8Csbil N32hlbnstJKHyAzzTxIfRxkud8wrhnezIw8U+NhZDujRZXXBtcd3dTrQrLRRii+xemab NXDfIWVLbktYERB0lbf1ZZueOAGH6RN0JYkNk5aZZupjJEBkX2eAHM6rd0rT6kWgRRTP 4gqRHuESBFB3pudorp82sTlWJisgb0cfLXaLPM2C9GvCFnMjSTstIUNDTsV1dOomwz5f r6Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KeR/0VWopxy2Ah3tDJ14Y54iJ3/keRImCYHuxTx/EW4=; b=cVXRG4DRsYoXLkiqLBEdnbnNbU2MFJCDKpDMmfqGzBy2dpT+oDU8wDKNYVcJjUNXvG UjD8VwRq5aJqT6oqcgzMBVrAmYTAhezkpYvwRgpodE6BK7sUBsmLtd9RUImxvDYbhwI2 8tR9hba8BvaJFETjbkZrCkh8lGrEaRCyqlSk057xwTKtxVmdyFESQNldUp6mg10r80Vk 6FqZBSpizXM601EPcrlSDGqf69v/E8M6f6KL3uhAW5jJPg2f2WbYCTJrLLdHvQKsGDrH tI4yLOP5uUbyjdGXFQdOfCH2HSk518lL8m+NTZHmhbbsmn5Fj3GCJQm0TbhlZvWCydzw 8zrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YBXsgOq2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f190si5166882oig.229.2020.01.28.06.19.42; Tue, 28 Jan 2020 06:19:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YBXsgOq2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730079AbgA1OSr (ORCPT + 99 others); Tue, 28 Jan 2020 09:18:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:42830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730343AbgA1OSm (ORCPT ); Tue, 28 Jan 2020 09:18:42 -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 DA7CB21739; Tue, 28 Jan 2020 14:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221122; bh=B1qp81a6OQZ0yRws+WSx9Njv0sIKFJa6YhmnchQKWfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBXsgOq2rojmPIInPpNO19IMaDNQOKhl4DpnJ5lEyxc/VFK+aCt5m4P5VLUSLk6KE y+mEQX7ONKFAVVV4vqRVIwyNySanDCr41JueWMsfKFVt+ZJlo2s1XdpaUHSI3vRMhe GOKd4FuD516HoczvKBLq+8NswN7ZC20jOc7g8Vm0= 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.9 097/271] net: sh_eth: fix a missing check of of_get_phy_mode Date: Tue, 28 Jan 2020 15:04:06 +0100 Message-Id: <20200128135859.818138891@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 49300194d3f9f..6f8d4810ce979 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -2929,12 +2929,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) -- 2.20.1