Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7914481rdb; Thu, 4 Jan 2024 11:37:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHl3QXUCIZhyhFPCosiXPeLlBInvF7lNcKqTm7p37iAyI1OtM46IJBxeXOmoRG00FN54Kp4 X-Received: by 2002:a17:907:9704:b0:a28:e1a4:ae46 with SMTP id jg4-20020a170907970400b00a28e1a4ae46mr1373351ejc.13.1704397052667; Thu, 04 Jan 2024 11:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704397052; cv=none; d=google.com; s=arc-20160816; b=Wpqv8bwNU3xSKkeOIHfNYxxBM4JKx2P3RdChH/JQG1rk02sHRk7R4REEpHF0RLI6ge +m31UbuZvv3Cm++FSm72V7po/FpBXrwulvksMZQXnWXhUc+lN03wiO7FQ4PfofjsOXuw mU7b85GT7ixn2b4UETk5ItFsC/bWWv/pP8pkijHXfBUUwU8uc20zGxZC6aFi5dTHMsIb pOiLoy6FTQU/YZAHwOp9OZhfKl4gspBKDp/qYs5ztFgZJRmbR0T8IqNjgtWILGY4oFkX xiyKcf9jHwTNmq6apERvR5qyyQEAbvBsAKA8x3XaYosgiHBVDFJC9e3wdDHb9DPbrkkV uXRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5jyLPzGlkBzpMC1Ie2DgS7N7g7HFIfbpKPqTLTs2R68=; fh=n6O/21fWtQJErp2+ks1vNwQ08wWZ3eyfCweCaUqk1kk=; b=oMdze+H4pQyd3cGW3gB1xuc1Xv9OV2YXFryZhah99qYUF3Q58zO39lj59ANpzVM5Sz yAo2Bu6hMWBcgChCJpIly3TuRHgShyOmRLO6qUT3x+7aCMYgO8BvFFuh9DuW6uYRu+fr xR/0uXHp2CZ9r33Mrh9r80gECKmrkDDXrLfb75N7pOgvhwuzOEa+Lg7gjMPoJiKlpkf4 usebakRCPg18lxH0gr/tsPWaDOnYf+lWoPeg4Sbz+wvDc3I+rkLyCd0YseRdvLOSMMoQ 0ehB5Yn2/fBAt5EAhisKE1I5H9akR6YhhOdEh7CTHCJDD5sN7wj9BhbXBxwzymr7+VWs sWtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=hjK4Bvhw; spf=pass (google.com: domain of linux-kernel+bounces-17173-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17173-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qx12-20020a170906fccc00b00a276dc72065si199ejb.376.2024.01.04.11.37.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 11:37:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17173-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=hjK4Bvhw; spf=pass (google.com: domain of linux-kernel+bounces-17173-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17173-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6AA5D1F22CD8 for ; Thu, 4 Jan 2024 19:37:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A40732CCBD; Thu, 4 Jan 2024 19:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="hjK4Bvhw" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB35E2CCBA for ; Thu, 4 Jan 2024 19:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5ce9555d42eso647725a12.2 for ; Thu, 04 Jan 2024 11:36:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1704396985; x=1705001785; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5jyLPzGlkBzpMC1Ie2DgS7N7g7HFIfbpKPqTLTs2R68=; b=hjK4Bvhwta+qX9IgS73+a13RTbjKwG9l1YvUBiE7VYGu9Wq5EPTvwsakzroPRIyslY jVeo3rNztqECE279ag2ZNeUYYbuvMt9vAlfU+zomc4ivz3SgXVRDORg2W/wLEWO/1GaO AwNJoV7aWUTDqMsdq0QNKYJKLOou/2Hr/+8UEBR0a+K41i5n540I1T+VtzfBX5llE6lP Ds0pscuu0HHNr70Sl7PzREpIqSxNdBn6ikB+Hhd6y1e3SQgfBbszAJJ5lIWWUOyLmksM UB+m+JMvwBdIs/bdzMJGX1FtahhGfDPSPyULn1GxbukF6jDikHukID2LYXF1KdWZaeAO p66g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704396985; x=1705001785; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5jyLPzGlkBzpMC1Ie2DgS7N7g7HFIfbpKPqTLTs2R68=; b=ZlUsjxjVam7lKOM7c77bBeONKYp148zM1wFGXg/efKo4FFQKIP9Bm1QxtUfACpAoei Mmc/s6I2tMLmywE2gMNe8q9ZLavc/gXUxOG9smTMgccRf2FJsiMeBJY9s067NSnuNYTw ob9QCL2zdJRxvrFF75zT2Y682JEfNL/l6vFDIBxUQVdD9yKBZ8m1eYB1PIExdk6qoS6c X1l3hgCeqFVAclVF22VqrfT9EVzuWYIKm7n0BrawAXP9kk22wmqJzGa27V+VtTArV2Mv K31Tt8obUbtE0zGiOF4xC8rMK+H1rn4lls/mpqrH3Nlb19gVYirhgVikbVXOvFEBJXoo SrWw== X-Gm-Message-State: AOJu0YzWDmTprM0jbYP4araTYQ2jk6s/4mhDcw9eRoo5pCurCLccd4ff MjBRMHxQXlGvPqdywGhv3tNaNgWQsfJIlg== X-Received: by 2002:a05:6a20:8415:b0:197:5be1:262b with SMTP id c21-20020a056a20841500b001975be1262bmr1108314pzd.83.1704396984958; Thu, 04 Jan 2024 11:36:24 -0800 (PST) Received: from ghost ([2601:647:5700:6860:bd91:d703:f34:7cf7]) by smtp.gmail.com with ESMTPSA id ko7-20020a056a00460700b006d9a0694f93sm23013pfb.205.2024.01.04.11.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 11:36:24 -0800 (PST) Date: Thu, 4 Jan 2024 11:36:22 -0800 From: Charlie Jenkins To: Dan Carpenter Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kernel test robot , Dan Carpenter Subject: Re: [PATCH v2 4/4] riscv: Convert relocation iterator to do-while Message-ID: References: <20240103-module_loading_fix-v2-0-292b160552c9@rivosinc.com> <20240103-module_loading_fix-v2-4-292b160552c9@rivosinc.com> <39727434-a265-484b-9ee6-da6611487b47@moroto.mountain> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <39727434-a265-484b-9ee6-da6611487b47@moroto.mountain> On Thu, Jan 04, 2024 at 03:35:55PM +0300, Dan Carpenter wrote: > On Wed, Jan 03, 2024 at 12:22:03PM -0800, Charlie Jenkins wrote: > > Use a do-while loop to iterate through relocation entries to prevent > > curr_type from being marked as uninitialized. > > > > Signed-off-by: Charlie Jenkins > > Fixes: d8792a5734b0 ("riscv: Safely remove entries from relocation list") > > Reported-by: kernel test robot > > Reported-by: Dan Carpenter > > Closes: https://lore.kernel.org/r/202312130859.wnkuzVWY-lkp@intel.com/ > > --- > > arch/riscv/kernel/module.c | 26 +++++++++++++++++++++----- > > 1 file changed, 21 insertions(+), 5 deletions(-) > > > > diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c > > index ceb0adb38715..581e425686ab 100644 > > --- a/arch/riscv/kernel/module.c > > +++ b/arch/riscv/kernel/module.c > > @@ -633,15 +633,31 @@ process_accumulated_relocations(struct module *me, > > bucket_iter->bucket, node) { > > buffer = 0; > > location = rel_head_iter->location; > > - list_for_each_entry_safe(rel_entry_iter, > > - rel_entry_iter_tmp, > > - rel_head_iter->rel_entry, > > - head) { > > + rel_entry_iter = > > + list_first_entry(rel_head_iter->rel_entry, > > + typeof(*rel_entry_iter), head); > > + rel_entry_iter_tmp = > > + list_next_entry(rel_entry_iter, head); > > + > > + /* > > + * Iterate through all relocation entries that share > > + * this location. This uses a do-while loop instead of > > + * list_for_each_entry_safe since it is known that there > > + * is at least one entry and curr_type needs to be the > > + * value of the last entry when the loop exits. > > + */ > > I know that I reported this static checker and all, but actually after > reading this comment, I think we should stay with original code. So > long as we know the list has "least one entry" which we do then the > original code worked fine. > > To be honest, I probably would not have even reported this static > checker warning except that I saw there were some other issues and > thought "Eh, why not throw this warning in as well, in case the list > can be empty." That makes sense, I will drop that patch. - Charlie > > The other three patches look good. > > regards, > dan carpenter >