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 66B0DC3DA7A for ; Wed, 28 Dec 2022 15:08:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233631AbiL1PIy (ORCPT ); Wed, 28 Dec 2022 10:08:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233630AbiL1PIo (ORCPT ); Wed, 28 Dec 2022 10:08:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 958CF13DC1 for ; Wed, 28 Dec 2022 07:08:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4E0F8B8171F for ; Wed, 28 Dec 2022 15:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D4E7C433D2; Wed, 28 Dec 2022 15:08:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672240121; bh=hvEaW+R/g4ESMPE5f6j9wm+HHJ34mDcZ+PHSC8ogkAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wlMvIyCbSxePrMdB9K8ICUCOpFEYlr7AJv2D4JYdvW2gE25Ja0aCo7A+7cQDuWmFc mkDUyGZZy3jRbnv00hQCGcb61SwicQY+ibKrvB4n9BJAXb+0vajzUwEiWmn56B7bHs d0Do4/3b9EO3HWjik/gQaBpfbc4QIDNk0TN1GVM0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, YueHaibing , Yosry Ahmed , Roman Gushchin , Kamalesh Babulal , David Rientjes , Johannes Weiner , Shakeel Butt , Shuah Khan , Tejun Heo , zefan li , Andrew Morton , Sasha Levin Subject: [PATCH 6.0 0120/1073] selftests: cgroup: fix unsigned comparison with less than zero Date: Wed, 28 Dec 2022 15:28:28 +0100 Message-Id: <20221228144331.297733888@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144328.162723588@linuxfoundation.org> References: <20221228144328.162723588@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: YueHaibing [ Upstream commit 333d073dee3a6865171d43e3b0a9ff688bff5891 ] 'size' is unsigned, it never less than zero. Link: https://lkml.kernel.org/r/20221105110611.28920-1-yuehaibing@huawei.com Fixes: 6c26df84e1f2 ("selftests: cgroup: return -errno from cg_read()/cg_write() on failure") Signed-off-by: YueHaibing Reviewed-by: Yosry Ahmed Acked-by: Roman Gushchin Reviewed-by: Kamalesh Babulal Cc: David Rientjes Cc: Johannes Weiner Cc: Shakeel Butt Cc: Shuah Khan Cc: Tejun Heo Cc: zefan li Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- tools/testing/selftests/cgroup/cgroup_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c index 4c52cc6f2f9c..e8bbbdb77e0d 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.c +++ b/tools/testing/selftests/cgroup/cgroup_util.c @@ -555,6 +555,7 @@ int proc_mount_contains(const char *option) ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size) { char path[PATH_MAX]; + ssize_t ret; if (!pid) snprintf(path, sizeof(path), "/proc/%s/%s", @@ -562,8 +563,8 @@ ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t else snprintf(path, sizeof(path), "/proc/%d/%s", pid, item); - size = read_text(path, buf, size); - return size < 0 ? -1 : size; + ret = read_text(path, buf, size); + return ret < 0 ? -1 : ret; } int proc_read_strstr(int pid, bool thread, const char *item, const char *needle) -- 2.35.1