From patchwork Sun Jul 2 18:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 698428 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp1420127wrs; Sun, 2 Jul 2023 11:48:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65Z1F707h8EZN4rQD/G4sxTBZOle3M5u2u8z7lSYhRa7NP50/vjgpPtjX6ipw4yM7FCACh X-Received: by 2002:adf:dfc5:0:b0:313:f2bf:4c3c with SMTP id q5-20020adfdfc5000000b00313f2bf4c3cmr10620132wrn.24.1688323686126; Sun, 02 Jul 2023 11:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688323686; cv=none; d=google.com; s=arc-20160816; b=ClWJDuk+6k4QbCDEH0teIu3KPYcnzsff9CpsIj9RgHivafKDV4c/paJbae6Ly3xx4k 5Y96w6Dd7t6hmeoyGKbgIsYgaeCtDjviZp6zjXuCrF3LEQkfrzkOVYlXU8OrMnfHzvPp V4kesJPUfGt4pGqw2FCFJwqEHYFCOrIrZQ9eDb7VLeW02NKiiY+ACq1YhhmYHkvi9YAU pDtOLPobGtffIJbdESbgziZ0kiwQ3/Cm3kdOpf6q6gm3Bv99my96HnfSN0Ug35aFgf6j u/cRBpinpXo5xfmkCXrLQvH245NYtWnAE26W68DZ4MSIGcQpmkB4emG6EZu8iKG5sv6v 4MlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=bKJyCNzNin42FjJ1pwn73xu4mM/aC824/9cgcJLa5Lc=; fh=+AE76heQqzghvN8yE2slzPS7aSWO9R4gVtUgC5aJcqY=; b=eQ0wp7ESrm0j2xMhe0jKaKaGItfsGCBkY6ZHR69sxY5KV6GaGHUhvprGBg/sJSCMFD hNd7RxYkFxBMME2sUWDPEx7OkJu2SNdlAe1r2EENdMu/S23S2j6nrT30LaHteARIWy3N h/0M35D27zkHnqb/96GGxEvl3C8ug2938cMLEjDkG9jZnp+VwksrV1/dwAnzV+KQsG/G Lk9mzH0g5zwFn8nYh4/CoM5CT1kCgU4QMvyY1O4p0N+pthdaZYGCBcEE9ruAcxumf90U cVFncmyqtl5KtrKNd+a4sHiyJfi4F0sKdm+j7vESW2E5vMshJSoim/QU8N2oOffGf5Lw mLnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VJ9h8cDW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id c5-20020a5d63c5000000b00311112d9e4dsi12093103wrw.582.2023.07.02.11.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 11:48:06 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VJ9h8cDW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 083C18633D; Sun, 2 Jul 2023 20:48:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="VJ9h8cDW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C1F5586342; Sun, 2 Jul 2023 20:48:01 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (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 1D01186339 for ; Sun, 2 Jul 2023 20:47:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bhupesh.sharma@linaro.org Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-55adfa72d3fso1879217a12.3 for ; Sun, 02 Jul 2023 11:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688323677; x=1690915677; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bKJyCNzNin42FjJ1pwn73xu4mM/aC824/9cgcJLa5Lc=; b=VJ9h8cDWaukuGMPwiwqOmXeLq8Qy3rUMD+V3ZhVjOhWe0tlfgEdY75Wwv3eYnIMiMV AiuXXwfON9xJd7uO/98AfHHKzc4OMNQh4Gv01Lov8nhoqWH33riiG32v622ji9aKiRjy D+eTsIksHbfBPbtDqYcO+No6gPasyRdFciAavaf2Rl9TIpmBq6+QxHmj+AjKQ0yIP+GN qJnNCkjqhvyY3ybCpINI/p97idCAMxfULL/WXx9DpF+2UQ8fTRso8QnUxIAz0dOAaJa0 k+gyZzLVcX107JQohsOFRPdOrtcsdm7wQOEd1KsXToy5L+1yMxeHPxWoLjSgGWYzb/Ii Fl6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688323677; x=1690915677; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bKJyCNzNin42FjJ1pwn73xu4mM/aC824/9cgcJLa5Lc=; b=alu9JuLNYmotcVQudB4xJlFgfwDsFkRM3hOsU3wbL3gV2Ij72r1ZA/04ZP6IbFOkmR KLJFsgk6RzDZdfaThCTIjDzoHPY/sdL34wreKe/A30UchslKrwUy8buWhKwvjFYCdwHw oqQ83uXu3uaxtUge5UQIDaxDad8+NX5kNRuHcmcUTaGNzJAjex2r4/MXVzXuOm6b+4CS ldXJu2611p5WaNMC8+9QQpDDVTwAmjPoDl324gQP5BQm6lPs9Ju5yBbsifm5gK2ZjVTW N1ukTKB2tmdGQrf1pWmTbz4YgE5Ht1BeNSqhaqZWtzVYKSa7gfaSoAO7iYBBoLytKvwQ JlPA== X-Gm-Message-State: AC+VfDxQs5YbAPc6lr7sILMUSEC+ZjqlG+6cqFJxj+6CUWSFjUvYJw8s rnalh7539Ic7IAy+DE+WL1cN/ti0w70drp8PIkY= X-Received: by 2002:a05:6a20:948a:b0:12b:de8:929d with SMTP id hs10-20020a056a20948a00b0012b0de8929dmr6142784pzb.16.1688323676852; Sun, 02 Jul 2023 11:47:56 -0700 (PDT) Received: from localhost.localdomain ([223.233.68.54]) by smtp.gmail.com with ESMTPSA id t19-20020a63dd13000000b0050f85ef50d1sm13557649pgg.26.2023.07.02.11.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 11:47:56 -0700 (PDT) From: Bhupesh Sharma To: u-boot@lists.denx.de Cc: jonas@kwiboo.se, patrice.chotard@foss.st.com, kever.yang@rock-chips.com, eugen.hristev@collabora.com, marek.vasut+renesas@mailbox.org, sjg@chromium.org, trini@konsulko.com, bhupesh.sharma@linaro.org, bhupesh.linux@gmail.com Subject: [PATCH] phy: phy-uclass: Add a missing error handling path Date: Mon, 3 Jul 2023 00:17:47 +0530 Message-Id: <20230702184747.2556968-1-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Since function 'phy_get_counts()' can return NULL, add handling for that error path inside callers of this function. Signed-off-by: Bhupesh Sharma --- drivers/phy/phy-uclass.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 629ef3aa3d..c523a0b45e 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -229,6 +229,11 @@ int generic_phy_init(struct phy *phy) if (!generic_phy_valid(phy)) return 0; counts = phy_get_counts(phy); + if (!counts) { + debug("phy_get_counts returns NULL\n"); + return -ENODEV; + } + if (counts->init_count > 0) { counts->init_count++; return 0; @@ -275,6 +280,11 @@ int generic_phy_exit(struct phy *phy) if (!generic_phy_valid(phy)) return 0; counts = phy_get_counts(phy); + if (!counts) { + debug("phy_get_counts returns NULL\n"); + return -ENODEV; + } + if (counts->init_count == 0) return 0; if (counts->init_count > 1) { @@ -305,6 +315,11 @@ int generic_phy_power_on(struct phy *phy) if (!generic_phy_valid(phy)) return 0; counts = phy_get_counts(phy); + if (!counts) { + debug("phy_get_counts returns NULL\n"); + return -ENODEV; + } + if (counts->power_on_count > 0) { counts->power_on_count++; return 0; @@ -341,6 +356,11 @@ int generic_phy_power_off(struct phy *phy) if (!generic_phy_valid(phy)) return 0; counts = phy_get_counts(phy); + if (!counts) { + debug("phy_get_counts returns NULL\n"); + return -ENODEV; + } + if (counts->power_on_count == 0) return 0; if (counts->power_on_count > 1) {