From patchwork Sat Sep 12 21:45:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1362933 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=UT/QlWIm; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BpmR42W8Jz9sT6 for ; Sun, 13 Sep 2020 07:46:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16202822ED; Sat, 12 Sep 2020 23:46:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="UT/QlWIm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24176822B5; Sat, 12 Sep 2020 23:46:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (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 CAE3582242 for ; Sat, 12 Sep 2020 23:46:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x744.google.com with SMTP id g72so13417577qke.8 for ; Sat, 12 Sep 2020 14:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wheQFDE9vC52doLZfedT2oDfQmTRGr44alMZK/nRkng=; b=UT/QlWIm/dsNPqHgmDmtLR4BytBNAr7K3ym/PrGGYRx2T09MasDhawtRUGFInBzL8j AnDma5gad4J3P9LUqJKgSvshOnnmcNFooJJ1iSL606Sy/KRREAAKbObdfwHkHaB4g8+e nDkvPWiXi8hKlg7qnuJ66E7zD5cPeZvIx2K6BDkSRU+R2ue5js7quugj+DKD+bdUtmcZ uqWr/Jf1zaEpX1LQdwqyv0yf5U/PNHh4r/Z0TzTvG7XfwvclxVYMxvUbAPaC7FCEDsdQ +C3nn5uWrP6Zga8kZ+r27mob+TcpZSNyuNGM4n6LNnB+Y5TLfo1uRvGF2PizobGDsvUm iYoA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wheQFDE9vC52doLZfedT2oDfQmTRGr44alMZK/nRkng=; b=VtMtHIYY9ZQoiy87RCH/G6syZ1wf0jkkO/sHZcyZ07NYzM5tG36rP9NnAL1oMexfAH X8pCeItyOTkGka0POcrk9zUn+4hy/qMjZoFMLBN448NTGXaJJ+g8AIjRwQnHvkPNN/UE twd1+jviQIbv1ArfYb6axj4wu+xN5KlPinrV37F4IKT96CoPZ7C+v+enqwlVRJMuq/Wt 81J4Y6cz+mXUZchh2AenR/T1EYktImr66u1VwE5fwbKSV8S32IHW/UDa42/RgpPWkLCy 1sDl3kcgmpnuaGtzGgAQLYf5uv2udaXa/1sqMJ69iOAfTvbBQGZDKuhM+HfvwsOXGIJ+ b18A== X-Gm-Message-State: AOAM533/4TEr7n8DNnEVY4RCwXVO2qbDtLGPpTLZ/vnQ1fmJel/WWPXT Yf/4b4RrwW0ycQMcCFBYPvz40xPmufpOeA== X-Google-Smtp-Source: ABdhPJxZ71Rp5r4DroljoItzTckjGo5agzxlLx3mDtcDcJ1H5vmGyPvDJTMNTQzWKVvnm3LS9XvORg== X-Received: by 2002:a37:a392:: with SMTP id m140mr6783148qke.195.1599947161468; Sat, 12 Sep 2020 14:46:01 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id k20sm8745419qtb.34.2020.09.12.14.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 14:46:01 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Simon Glass , Heinrich Schuchardt , Joe Hershberger , Sean Anderson Subject: [PATCH 1/3] dev: Disambiguate errors in uclass_find Date: Sat, 12 Sep 2020 17:45:42 -0400 Message-Id: <20200912214544.362594-2-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200912214544.362594-1-seanga2@gmail.com> References: <20200912214544.362594-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean There are two cases where uclass_find can return an error. The second is when the uclass has not yet been init'd. The first is when the driver model has not been init'd (or has been only partially init'd) and there is no root uclass driver. If LOG_SYSLOG is enabled and LOG_DEFAULT_LEVEL is set to LOGL_DEBUG or higher, log_syslog_emit will try to call net_init before initf_dm has been called. This in turn (eventually) calls uclass_get for UCLASS_ETH. If the second error occurs, uclass_get should call uclass_add to create the uclass. If the first error occurs, then uclass_get should not call uclass_add (because the uclass list has not been initialized). However, the first error is expected when calling uclass_get for UCLASS_ROOT, so we add an exception. There are several alternative approaches to this patch. One option would be to duplicate the check against gd->dm_root in uclass_get and not change the behavior of uclass_find. I did not choose this approach because I think it it is less clear than the patch as-is. However, that is certainly subjective, and there is no other technical reason to do it this way. Another approach would have been to change log_syslog_emit to abort if it is called too early. I did not choose this approach because the check in uclass_find to see if gd->dm_root exists implies that functions in its file are allowed to be called at any time. There is an argument to be made that callers should ensure that they don't call certain functions too early. I think it is better to code defensively in these circumstances to make it easier to discover such errors. Signed-off-by: Sean Anderson --- drivers/core/uclass.c | 16 +++++++++++++++- test/dm/core.c | 2 +- test/dm/test-main.c | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index c3f1b73cd6..2e098034c9 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -19,6 +19,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -27,7 +28,7 @@ struct uclass *uclass_find(enum uclass_id key) struct uclass *uc; if (!gd->dm_root) - return NULL; + return ERR_PTR(-EAGAIN); /* * TODO(sjg@chromium.org): Optimise this, perhaps moving the found * node to the start of the list, or creating a linear array mapping @@ -144,6 +145,19 @@ int uclass_get(enum uclass_id id, struct uclass **ucp) *ucp = NULL; uc = uclass_find(id); + if (IS_ERR(uc)) { + /* + * If we're getting the root uclass, then uclass_find will fail + * with -EAGAIN (since it thinks there's no uclass list to + * search), but we need to add it anyway (since otherwise it + * would never be created). + */ + if (PTR_ERR(uc) == -EAGAIN && id == UCLASS_ROOT) + uc = NULL; + else + return PTR_ERR(uc); + } + if (!uc) return uclass_add(id, ucp); *ucp = uc; diff --git a/test/dm/core.c b/test/dm/core.c index 8ed5bf7370..a4e0ac06f9 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -733,7 +733,7 @@ static int dm_test_uclass_before_ready(struct unit_test_state *uts) gd->dm_root_f = NULL; memset(&gd->uclass_root, '\0', sizeof(gd->uclass_root)); - ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST)); + ut_asserteq_ptr(ERR_PTR(-EAGAIN), uclass_find(UCLASS_TEST)); return 0; } diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 38b7b1481a..6ff07a5d32 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -70,7 +70,7 @@ static int dm_test_destroy(struct unit_test_state *uts) * check that here before we call uclass_find_device(). */ uc = uclass_find(id); - if (!uc) + if (IS_ERR_OR_NULL(uc)) continue; ut_assertok(uclass_destroy(uc)); } From patchwork Sat Sep 12 21:45:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1362935 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=tk/FdJXC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BpmRW224pz9sT6 for ; Sun, 13 Sep 2020 07:46:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1AA1282317; Sat, 12 Sep 2020 23:46:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="tk/FdJXC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EF5BA82314; Sat, 12 Sep 2020 23:46:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) (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 D20AC8229B for ; Sat, 12 Sep 2020 23:46:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x843.google.com with SMTP id n10so10727936qtv.3 for ; Sat, 12 Sep 2020 14:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S9vxybhFadf6IDv9nv0XH9aZkuaunoDm0omvyme+V18=; b=tk/FdJXCll0lS2ElkqO+6M6RenGedCtT40HsmLIJETOy7AyrUzr0L8g3hBdWk0Sqj3 pKMWuhg/itwrexwsrxUw1s2vWphbCP2VIEqNGR46xPZU3B5C3xqGY6rpEC98IcffRlrK +2zbwj29vh4s/25WIy6Idb3d8koEFIHrGWf3LCF8TvOUw1Q0ZaM5pxUwCafAFrHKB2Zd n+EPFNus0IOTgjwbHoyEHvPmHKJdwfgRS6PmBtD+ZdTpVo35NFml00Af5eet+4Fgp6Cr UpIPpsH1VXo4t2B1qgsaAtcMfO3R5Jki+ePgyaH3uyke4nhSL8XgCnpzvI3U/tkD5qv/ LSYg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=S9vxybhFadf6IDv9nv0XH9aZkuaunoDm0omvyme+V18=; b=Hi2dpq5RHA2xaL8ApOnm9ltgwQr1lzEJQBEUPOJKsoc5mjYxx0Ii0B8+ytcSoNBu4e KFp8O4rOENthj5pSDpJnUDrSO+ASS+KgLqoM3I1oK9ozT2hpU5YvogCTQqf8X3m+e4pF P7QA0ZhHj2xokFpQMsjhMNkaoRPeW6+4racW7pTsQA5ozjXgem0/fDYVqIbD8WDllzaz 182+Ot8npLrRlzQQHSPjgd5MjeCFx5yR8Ksgn2E/IOoQFAz7k1MWoI5cqKGVNm2GezbN aratcMGiNl+nkZ3LZht8AW5Vbo2K5lrF5bKTT/I3J9/ywUqT8gpGZ0dDhHb+5RFoclEt 3o2w== X-Gm-Message-State: AOAM530zDmmYCf1RwhJBxmQIOc9S9CthrVmFFpMMX/BfXEk25K3+BwJq sV2HSZUvLjWGqNow7KNvv7s4YK0RycqI7g== X-Google-Smtp-Source: ABdhPJwAs1zIGDVJKDnWMjp2eUHbFZ218V6wJud1qNBVz9x2XaZzX21JgS+eS52B66D6HHa3ljz9VA== X-Received: by 2002:ac8:fb3:: with SMTP id b48mr7812583qtk.16.1599947162478; Sat, 12 Sep 2020 14:46:02 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id k20sm8745419qtb.34.2020.09.12.14.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 14:46:01 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Simon Glass , Heinrich Schuchardt , Joe Hershberger , Sean Anderson Subject: [PATCH 2/3] net: Expose some errors generated in net_init Date: Sat, 12 Sep 2020 17:45:43 -0400 Message-Id: <20200912214544.362594-3-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200912214544.362594-1-seanga2@gmail.com> References: <20200912214544.362594-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean net_init does not always succeed, and there is no existing mechanism to discover errors. This patch allows callers of net_init (such as net_init) to handle errors. The root issue is that eth_get_dev can fail, but net_init_loop doesn't expose that. The ideal way to fix eth_get_dev would be to return an error with ERR_PTR, but there are a lot of callers, and all of them just check if it's NULL. Another approach would be to change the signature to something like int eth_get_dev(struct udevice **pdev) but that would require rewriting all of the many callers. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- include/net.h | 2 +- net/eth-uclass.c | 3 +++ net/net.c | 15 +++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/net.h b/include/net.h index 1bf9867f8c..b80b13ae7c 100644 --- a/include/net.h +++ b/include/net.h @@ -593,7 +593,7 @@ extern int net_ntp_time_offset; /* offset time from UTC */ #endif /* Initialize the network adapter */ -void net_init(void); +int net_init(void); int net_loop(enum proto_t); /* Load failed. Start again. */ diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 0d9b75a9a2..1f59d24f54 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -75,6 +75,9 @@ struct udevice *eth_get_dev(void) struct eth_uclass_priv *uc_priv; uc_priv = eth_get_uclass_priv(); + if (!uc_priv) + return NULL; + if (!uc_priv->current) eth_errno = uclass_first_device(UCLASS_ETH, &uc_priv->current); diff --git a/net/net.c b/net/net.c index 28d9eebf9d..3afd0d6fb0 100644 --- a/net/net.c +++ b/net/net.c @@ -353,12 +353,19 @@ void net_auto_load(void) tftp_start(TFTPGET); } -static void net_init_loop(void) +static int net_init_loop(void) { if (eth_get_dev()) memcpy(net_ethaddr, eth_get_ethaddr(), 6); + else + /* + * Not ideal, but there's no way to get the actual error, and I + * don't feel like fixing all the users of eth_get_dev to deal + * with errors. + */ + return -ENONET; - return; + return 0; } static void net_clear_handlers(void) @@ -373,7 +380,7 @@ static void net_cleanup_loop(void) net_clear_handlers(); } -void net_init(void) +int net_init(void) { static int first_call = 1; @@ -396,7 +403,7 @@ void net_init(void) first_call = 0; } - net_init_loop(); + return net_init_loop(); } /**********************************************************************/ From patchwork Sat Sep 12 21:45:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1362934 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=S7sD+bKv; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BpmRG2qXCz9sT6 for ; Sun, 13 Sep 2020 07:46:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 360938230E; Sat, 12 Sep 2020 23:46:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="S7sD+bKv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 044428230E; Sat, 12 Sep 2020 23:46:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (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 9C164822D7 for ; Sat, 12 Sep 2020 23:46:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x842.google.com with SMTP id t20so10695782qtr.8 for ; Sat, 12 Sep 2020 14:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zO4DmQn8HlmZgfXjTjlRIe1s9ubmNCmVC2KOh1N+rJE=; b=S7sD+bKvH+fYL77nklBEIXS1F7GGmH2nb9YrL4dLInDmLwdJIbZpuqTSa1dh4TRWPH Mi5z2gy7/jwq5M5ocSO17s0gtSCnOXhTSOnKHqNCbCoh3agcfnu/XZPiFY6wM/2HAoTs opSYuIUIkSTtvNPfdJWtdwKNVtLqriP23/ra5VLlcRRvRd6F3VlxtiHArCGEUe1nFhif Z6frkifzmrcK1lIRvwYQUaqqnLXzierRYli4aEnsnL6YwM5x4/9LlnpaFhwu27KfNaOT jqZwnlR6gAfRzoN+0N3t5acNLpwG3ApCNuvQKpDpNkSIJrhiCjUbs6vwB9BqYCkipB02 w/8Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=zO4DmQn8HlmZgfXjTjlRIe1s9ubmNCmVC2KOh1N+rJE=; b=ca8+DP4IcV5r/TIWN8jyYKAlgN4yG6mH1lVGX9jgGi79vbAocqiseuCWjbyArlMl/G 6VlwaG6fsIy/zWTfuuefSrReW//yJ94V9CdkPCnpXGpsLcGniwXEGMiuTHrxHk+IDK56 I5iPctqlz+1enmvcCa1yEHMwWuLzV8Za3Z49VB98pICSe4KN0VoMtFnWmnHDhwFv1LoV HFiY5MfS++vCZdiNSqMLSux074y3Ys+5oaCuFqP2LiOdA6Zhg5dK8064SYNLwdcKHsQv SfKjOnUufOTDpsx0TRWPe27b3EFnqkoeS6faKZRr8W5rA6A3HuteicP10e1u1JfymguR Tweg== X-Gm-Message-State: AOAM5335CfrEHsJfh9dzKZ8RQpcwavjxfE69cFtrlx7lWKzQD5ij5G2Y pMvCkrb8iFraRVhrbZ98K/sySDbGprTTEA== X-Google-Smtp-Source: ABdhPJw77LpjRz/E0xaiTI6/DAf+r7fu6zUM1SUqiAp7pcinhDHEBe/VaJZtMHESCz9kSxzCcmtX3A== X-Received: by 2002:ac8:6e90:: with SMTP id c16mr7717369qtv.17.1599947163451; Sat, 12 Sep 2020 14:46:03 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id k20sm8745419qtb.34.2020.09.12.14.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 14:46:03 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Simon Glass , Heinrich Schuchardt , Joe Hershberger , Sean Anderson Subject: [PATCH 3/3] log: syslog: Handle errors in net_init Date: Sat, 12 Sep 2020 17:45:44 -0400 Message-Id: <20200912214544.362594-4-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200912214544.362594-1-seanga2@gmail.com> References: <20200912214544.362594-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Since the previous patch, net_init now exposes some errors, so check for them. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- common/log_syslog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/log_syslog.c b/common/log_syslog.c index 149ff5af31..aaa0fcfa48 100644 --- a/common/log_syslog.c +++ b/common/log_syslog.c @@ -46,7 +46,9 @@ static int log_syslog_emit(struct log_device *ldev, struct log_rec *rec) processing_msg = 1; /* Setup packet buffers */ - net_init(); + ret = net_init(); + if (ret) + return ret; /* Disable hardware and put it into the reset state */ eth_halt(); /* Set current device according to environment variables */