From patchwork Wed Nov 23 14:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jit Loon Lim X-Patchwork-Id: 1708346 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DldmPAvm; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NHNpR6tL9z23mR for ; Thu, 24 Nov 2022 01:30:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7493E854B4; Wed, 23 Nov 2022 15:30:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=intel.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=intel.com header.i=@intel.com header.b="DldmPAvm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F16F1852CC; Wed, 23 Nov 2022 15:30:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 86DA7854B7 for ; Wed, 23 Nov 2022 15:30:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=jitloonl@ecsmtp.png.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669213848; x=1700749848; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=XEfXMyrRYdwmKQ6jtLO/NsMUbMKC5mhyDvIIfhyD/30=; b=DldmPAvmKi9JP0GbtZjz3fwMZcEosS0DG3f71xXqhSCIw1sPgbM0FD6L Ixfk6kYR1tMfVH+oiGLuNF+ydqTuXxYnTROJCLFIazPwy1lHSS2t6I0wB PtydjRZINxDl0lnJ3WGXNslbF0tNaqC5hzvxAXtF0du8H5kMgUA6WxZZ3 H1KECUA3q0tK9O/wrvArzqx4/dIeEj3ry7GSoCoke5YsS5C4zsqHV+2oz vmARQlFVIcP9OtXCDvUWiohQmWiqi0DZ2mZ7eniG9IzblbxTs9a4ALB+a h+Shdb3MIuHxFZsGQ04c2GwsCGZgP9qWeH9NIwvt6TyY15a31hPy1Rqnr g==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="301634882" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="301634882" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 06:30:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="672892148" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="672892148" Received: from pglmail07.png.intel.com ([10.221.193.207]) by orsmga008.jf.intel.com with ESMTP; 23 Nov 2022 06:30:35 -0800 Received: from localhost (pgli0028.png.intel.com [10.221.84.177]) by pglmail07.png.intel.com (Postfix) with ESMTP id 289D66F; Wed, 23 Nov 2022 22:30:35 +0800 (+08) Received: by localhost (Postfix, from userid 12048045) id 24D45E0095B; Wed, 23 Nov 2022 22:30:35 +0800 (+08) From: Jit Loon Lim To: u-boot@lists.denx.de Cc: Jagan Teki , Vignesh R , Marek , Simon , Tien Fong , Kok Kiang , Siew Chin , Sin Hui , Raaj , Dinesh , Boon Khai , Alif , Teik Heng , Hazim , Jit Loon Lim , Sieu Mun Tang Subject: [PATCH] ddr: altera: n5x: Return error if invalid DDR type is detected in argument Date: Wed, 23 Nov 2022 22:30:33 +0800 Message-Id: <20221123143033.22416-1-jit.loon.lim@intel.com> X-Mailer: git-send-email 2.26.2 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.6 at phobos.denx.de X-Virus-Status: Clean From: Tien Fong Chee Return error immediately if invalid DDR type is detected in argument so that uninitialized local variables such val and upd_val would not be used. Signed-off-by: Tien Fong Chee Signed-off-by: Jit Loon Lim --- drivers/ddr/altera/sdram_n5x.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ddr/altera/sdram_n5x.c b/drivers/ddr/altera/sdram_n5x.c index 5117a5c4cf..8d28cdbc03 100644 --- a/drivers/ddr/altera/sdram_n5x.c +++ b/drivers/ddr/altera/sdram_n5x.c @@ -2430,6 +2430,9 @@ static int set_cal_res_to_umctl2(struct ddr_handoff *handoff, upd_val = GET_LOWB_DATA(readw((uintptr_t)(handoff->phy_base + DMEM_MB_CDD_CHB_WW_0_1_OFFSET))); + } else { + debug("%s: Invalid DDR controller type\n", __func__); + return -ENXIO; } upd_val = max(val, upd_val);