From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7B41C433EF for ; Thu, 20 Jan 2022 23:16:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 53FC8838F8; Fri, 21 Jan 2022 00:16:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="KdXNdL8c"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C9E183325; Thu, 20 Jan 2022 08:35:18 +0100 (CET) Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E16668303A for ; Thu, 20 Jan 2022 08:35:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andy.chiu@sifive.com Received: by mail-pj1-x1035.google.com with SMTP id l16so4939474pjl.4 for ; Wed, 19 Jan 2022 23:35:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=V38IFHElPlt9dcWND5kQxn7sOzZo/VkZLv5qvrFMyaE=; b=KdXNdL8crXbXGnSwjYHUEi3cUZx0+dbhVfxm4n7W/pXI+V65ufxn/t2vamYiFSriBe RNozO8yW3gprN9bMXfwc0H8BHPWk8QFf5eBoloY6xHQzk5xbwA6UBC0l3HJAi4MjqXOu i3u2cAcvxpws6CeSFZE0jdF67AqWFkwyV/uiOTMtFwAoJGuCzhM524EalPkrk3BgN05h 3y9Sc2pxJuyC8dF9ghsPHCdEnSUwIAvC+rBesuCGg2fEeXCvgedPfEd00QRZYcXltpjj iEhiD3R/9d81ZdTpUbioK47SXZmZ55RxgFUGF8ORJx4IROphTEoqdk9tRbqmOJUWHTN7 zLKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=V38IFHElPlt9dcWND5kQxn7sOzZo/VkZLv5qvrFMyaE=; b=SvHgDgg6iXbWO2ZNfi/wVHlDBJ0BMpTatMUuxiOFMGd2m/c5g0SjDaTYul95f+WlLU 0NMnBIO2wAgzipEHy6yIAmM4L9c+sBqFrc7V6IRL6+Zpvawjs9K1/q//lCuw6geErsRU bqO52J1JJ1X5de8V6fHibOnTjq5mQZTvZ2cFo7LLbGZQ+WdYIoyDkZCJQw16C5tbVuFp VtAb9Vl0/b4O0FKR0h7ve7inE9Beln2+u9gVzWtKB9227No/H5hoH4CCWhdtl3C/OAZD BJbsBSYal6cosjhbyFcz41dvIsTX2j594vwhyhuSjB4aVdVILSH8IY+ukQjgqfHRd9df gg9g== X-Gm-Message-State: AOAM532OPXoKWGvcVYdRFzLFGesJuAkN5S2v+0z8Q8Ybmm+Wk8+2yIiY zyOA4MFf5Neio9plOJ8YrZoMgw== X-Google-Smtp-Source: ABdhPJzQ/10hvj2lK6UjZ9Wrm8UmM6GZwYIy9/2yrSbYg8VbXyUq69B70uus6qW1ocXWaUUzF7Pm6A== X-Received: by 2002:a17:90a:6b05:: with SMTP id v5mr9256263pjj.194.1642664112165; Wed, 19 Jan 2022 23:35:12 -0800 (PST) Received: from archlinux.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id k11sm2090796pfu.180.2022.01.19.23.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 23:35:11 -0800 (PST) From: Andy Chiu To: monstr@monstr.eu Cc: Greentime Hu , Andy Chiu , Joe Hershberger , Ramon Fried , u-boot@lists.denx.de Subject: [PATCH 1/3] net: xilinx: fix load access fault Date: Thu, 20 Jan 2022 15:34:18 +0800 Message-Id: <20220120073420.1887809-1-andy.chiu@sifive.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 21 Jan 2022 00:16:27 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Greentime Hu phy_connect() may fail by returning a NULL pointer. Thus, axiemac_phy_init() should handle the case or we may get an access fault when it tries to dereference it. Signed-off-by: Greentime Hu Reviewed-by: Andy Chiu Signed-off-by: Andy Chiu --- drivers/net/xilinx_axi_emac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 2ec76d0f52..3117dae05e 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -312,6 +312,10 @@ static int axiemac_phy_init(struct udevice *dev) /* Interface - look at tsec */ phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface); + if (!phydev) { + printf("phy_connect failed\n"); + return -ENODEV; + } phydev->supported &= supported; phydev->advertising = phydev->supported; -- 2.34.1