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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AC8BC77B76 for ; Tue, 18 Apr 2023 10:11:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbjDRKLN (ORCPT ); Tue, 18 Apr 2023 06:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230521AbjDRKLL (ORCPT ); Tue, 18 Apr 2023 06:11:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D9593AA0; Tue, 18 Apr 2023 03:10:48 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 25119168F; Tue, 18 Apr 2023 03:11:32 -0700 (PDT) Received: from [192.168.4.21] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 43FFF3F587; Tue, 18 Apr 2023 03:10:47 -0700 (PDT) Message-ID: <20487c94-7f81-cbf5-7136-c7f266eaf60d@arm.com> Date: Tue, 18 Apr 2023 11:10:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined To: Colin Ian King , Shuah Khan , Thomas Gleixner , linux-kselftest@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230417104743.30018-1-colin.i.king@gmail.com> Content-Language: en-US From: Vincenzo Frascino In-Reply-To: <20230417104743.30018-1-colin.i.king@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Hi Colin, On 4/17/23 11:47, Colin Ian King wrote: > In the unlikely case that CLOCK_REALTIME is not defined, variable ret is > not initialized and further accumulation of return values to ret can leave > ret in an undefined state. Fix this by initialized ret to zero and changing > the assignment of ret to an accumulation for the CLOCK_REALTIME case. > I was wondering how did you find this. Apart that: Reviewed-by: Vincenzo Frascino > Fixes: 03f55c7952c9 ("kselftest: Extend vDSO selftest to clock_getres") > Signed-off-by: Colin Ian King > --- > tools/testing/selftests/vDSO/vdso_test_clock_getres.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c > index 15dcee16ff72..38d46a8bf7cb 100644 > --- a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c > +++ b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c > @@ -84,12 +84,12 @@ static inline int vdso_test_clock(unsigned int clock_id) > > int main(int argc, char **argv) > { > - int ret; > + int ret = 0; > > #if _POSIX_TIMERS > 0 > > #ifdef CLOCK_REALTIME > - ret = vdso_test_clock(CLOCK_REALTIME); > + ret += vdso_test_clock(CLOCK_REALTIME); > #endif > > #ifdef CLOCK_BOOTTIME -- Regards, Vincenzo