From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 71F1837A4BA for ; Mon, 11 May 2026 12:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778501102; cv=none; b=nLoCqj5+AjMSPLrgnzPUKHw/5CN9WBGmm6AkzRqWy4Bv8xK6liqIVffswAzdx/ZgRaHE+F/anEQEnyg+HOB2tIk3H8ipYtCa/+2bqbQNeWJQSMY2+TEK20OSUH8SqEAzavSFlSzeC2kQFvUeMbmCftddROjBwAUrjqy6Ay9O3mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778501102; c=relaxed/simple; bh=+i9nY4yS0mmOkbjwKmwBLgjJ9pvH9NuVOTXbzoovY1k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=c98L9A/aGzCujEsfbeP7ki9u+hdBFY6VQR/B+QVYBNHItDe8ELf/1ZfmhTEKqcDPa9vEV5eg91u/KooJ58gVKGL0Qe1SF5pHVtLIjoMUP/q24eCj+iJOK72pSR+DpRUVdLd7PPkwXfXNtEoAayNAMud4bvvNn2n4hQ7ANuxP8Gw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=idsgeYUT; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="idsgeYUT" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4893940bb5eso25292885e9.3 for ; Mon, 11 May 2026 05:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778501100; x=1779105900; 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=cqTnF9n3Qex9jOfxNTk7/2y9GOIfeHPZuAdK9XxmLL4=; b=idsgeYUTnnQaeJsP7mq0J3y4XnHB8z8WZRQpeZGpl8ikv/KA9Q4NM0684iuFMn8uAa yjdkSlf2sXCuFnMQUCKU/tdPBm42S/pzQGWVgfjntq3P1BFvvFT0Tt4EDJGioktxsIwW UYhOk+0xwcSqDnUr/M2Yi1pu+SYp9EnxjoNDkOEpgQG/Ye/s4r4JBm8YvnvduiLr3o53 vE+ShIVz5GBv19VbFR448lV4dDnxix1XfO2596CFkyBnSyBd+q1vrQ1vkyUjAg+gsVYs 5YaVLt0WTyH2mqJ0S/EyIkQT5oHWK7pcraODrp5Xvcpvw5kwZtxGSRaENJ5cPR/VU7c9 JLpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778501100; x=1779105900; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cqTnF9n3Qex9jOfxNTk7/2y9GOIfeHPZuAdK9XxmLL4=; b=SuWqrnxAnpqDQkgQrxdqiUK3fTCVKT7wtR1whEWgy1P+rZiIneyGjJJPbDYJiXfVXu sRoK1jRlyYznnVOhdCfc9ANaM9oO7SEoKPyLJ0T+6e4DwfhCr+TdCZHwjWjJtuwflBqD KJH/WaFMz2L8aSML3ijNBzYPVUmVEkeISRdES6XWnhFADXxvVGBeiuIUSI7wNj0rfBRg hje2os9Fy8lGDaB6Q/pGhvEBAeA2ZEzaBkmiGgC0zSh1HVLw7d9KgD/E3sRhfPYq6afb EByS5InpudOzNyXF3Fk1HUW1FqHbQn/Rsv3rwXtmSKjXEBfjpP7RoRIWsFT5hd8RiIbO zV+Q== X-Forwarded-Encrypted: i=1; AFNElJ+JrKc132sNVLjubNGsyJ8Hwb1Wt/M0SpCm25hoERQQFq+R6tuVORRyk9lRdXDvuxV1xwDO7czG06QeUPY=@vger.kernel.org X-Gm-Message-State: AOJu0YwGOUh+UVQdZOSlyHMBeMHybGL3srOph2wZPGsXS/smd5bVQcYd QH9d7EdYiKcpwpRkfE0iG74ci903z1Og8tQU+CQ1dGyNV5myTxC2+Fqw X-Gm-Gg: Acq92OHO6tL+EFGJh3IEMhy+wj7rukfywJzdUB2sTL+/otTU3+nQuNtDGXwTmzgmmaV Q758AADmmJQZ7IX18NkbdaNsQfLcBE0FnzYQUDB4W5xR0EISjitFb5g1ggNfxztpb06rY4jnADY WF0iC5JQPzgoEUnKKB9R0rFOgocJ7w8uKFipDUJ4n3llzdZw+FTC8l6VdgsHgpLJkY/Bc4NYjjv PWTfvX6QwWatil2XfNrOhWucy8243s7VN3OM34w11Fy48F9v0JMARg2kUWBx5WpA5Oqa6hPNCim 4FKhUTEGWWXiLNvi+SLUQ1Uf0eGh9sIUJat67kr+X9YHU3Z5kaUpfCht1kptk2M+uFVGHcu7imX NCVGr0JiXna8YG4+gTrnGbgrGeMS4S6vUybvAs5rLteO8bLfQzuXR2J7WnpbXCFcUzEJQ1qDizM 90t5pVssc0l4a8HU1arm2BgIvYIsK1gBgrN0MYhWO6d0V7DjfT8lFgRIFszeBjHtxF0Xnu8P1NS g== X-Received: by 2002:a05:600c:1908:b0:489:1cd2:610a with SMTP id 5b1f17b1804b1-48e6767dfa2mr228143905e9.9.1778501099495; Mon, 11 May 2026 05:04:59 -0700 (PDT) Received: from fedora ([185.193.234.8]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45491ca2fd6sm26106273f8f.30.2026.05.11.05.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 05:04:59 -0700 (PDT) Date: Mon, 11 May 2026 13:04:56 +0100 From: Vishal Moola To: Hongfu Li Cc: tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, jthoughton@google.com, seanjc@google.com, zhangguopeng@kylinos.cn, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests/cgroup: Add NULL check after malloc in cgroup_util.c Message-ID: References: <20260511060853.1873161-1-lihongfu@kylinos.cn> 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: <20260511060853.1873161-1-lihongfu@kylinos.cn> On Mon, May 11, 2026 at 02:08:53PM +0800, Hongfu Li wrote: > Add NULL checks after malloc() in three helper functions to prevent > NULL pointer dereference on memory allocation failure. > - cg_name() > - cg_name_indexed() > - cg_control() > > These functions allocate memory with malloc() but previously called > snprintf() unconditionally, which would trigger undefined behavior > if allocation fails. > > Signed-off-by: Hongfu Li > --- Reviewed-by: Vishal Moola