Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1109576imm; Wed, 1 Aug 2018 10:20:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdXsqTB/2U4hY7w4fm7TR99Irh1Jj0LHYTMkv4cCUndOM7DpWsle/qhBEBsCe5n7RLo50nJ X-Received: by 2002:a63:5542:: with SMTP id f2-v6mr25929098pgm.37.1533144002700; Wed, 01 Aug 2018 10:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144002; cv=none; d=google.com; s=arc-20160816; b=xsOLKhkWeWZnMcBTmQFcHV277Ol7/Xf2lYGUX3EZFjwIZqsKMC67heEVxsXbkj/HxU C6j/8UJH5Avq9mrDLkD6AgFQGjYQZv4eDAndzD/xecqwZxedhGZd+rSLPURfheeXazlv MbP+avk5kNTxnWSFfveKuOBKEnzMdw3o5KghMdk5pxOB4HDIAjg+892/Utyg7M2Uy5H3 jzUbGjlVrBGM1eegmLXB64iY3P9izGRQrI5TWKUy7QGyeUjFeh+BcK/A6hc0vJ5g8XgX KqY5iLGpNI1OoX+dKJoxOqzvHvIBif3NM2aSmCRRvWH/TpcPIIHtlmz+uqN8e7s75BT5 LaVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VkbBeFlwUBnbk7SWgdDeXoLP7SPRWo+lpZmh7gVnVi8=; b=g6ClJajgpo1JTmX4ncuAu2fytwNyiJU/jkrpSspU8oivtBfzBIEoSwe4yGueax96eZ sL2gFsllFTiwI5OaDpNPbC5k6L/Z0IWAp4u58rrGLYuaZkwJeVzVQUJaCC1MdrwxFSOd cjTJk672Ulz8YsUlRqGFpHMqQ6NkBKGMZW7PwedXK30Zh/PZ0gV+qdWXjWOZHaX4yQZZ LAiqS4QYDLdClayIvdrzQO3u/6k29ADm0khVoA3619OMjQPCDueaqx+4w6FnxPfkIEKq Lqpc6m5lLP4ezSADcxJAIYm2P5WAOhKZjIYmJs3/gyrQbVKSnPzra2v8VF7ewGsB2oZE FE3A== ARC-Authentication-Results: i=1; mx.google.com; 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 u1-v6si14157439plk.97.2018.08.01.10.19.48; Wed, 01 Aug 2018 10:20:02 -0700 (PDT) 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; 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 S2404936AbeHATFB (ORCPT + 99 others); Wed, 1 Aug 2018 15:05:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47188 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404045AbeHATFB (ORCPT ); Wed, 1 Aug 2018 15:05:01 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9D057CD1; Wed, 1 Aug 2018 17:18:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Grygorii Strashko , Sekhar Nori , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 131/246] net: ethernet: ti: cpsw-phy-sel: check bus_find_device() ret value Date: Wed, 1 Aug 2018 18:50:41 +0200 Message-Id: <20180801165018.003185736@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Grygorii Strashko [ Upstream commit c6213eb1aee308e67377fd1890d84f7284caf531 ] This fixes klockworks warnings: Pointer 'dev' returned from call to function 'bus_find_device' at line 179 may be NULL and will be dereferenced at line 181. cpsw-phy-sel.c:179: 'dev' is assigned the return value from function 'bus_find_device'. bus.c:342: 'bus_find_device' explicitly returns a NULL value. cpsw-phy-sel.c:181: 'dev' is dereferenced by passing argument 1 to function 'dev_get_drvdata'. device.h:1024: 'dev' is passed to function 'dev_get_drvdata'. device.h:1026: 'dev' is explicitly dereferenced. Signed-off-by: Grygorii Strashko [nsekhar@ti.com: add an error message, fix return path] Signed-off-by: Sekhar Nori Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/ti/cpsw-phy-sel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/ti/cpsw-phy-sel.c +++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c @@ -177,12 +177,18 @@ void cpsw_phy_sel(struct device *dev, ph } dev = bus_find_device(&platform_bus_type, NULL, node, match); - of_node_put(node); + if (!dev) { + dev_err(dev, "unable to find platform device for %pOF\n", node); + goto out; + } + priv = dev_get_drvdata(dev); priv->cpsw_phy_sel(priv, phy_mode, slave); put_device(dev); +out: + of_node_put(node); } EXPORT_SYMBOL_GPL(cpsw_phy_sel);