From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 307F93ABD8D for ; Tue, 4 Aug 2026 20:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785876358; cv=none; b=T4sDAaFvTCXFPD3jKjj9OmtzW+DO4oZAPicT2Ot84RpWTnEiobaa/wef0j98XXAnH/sbbQ020Cpi9eGQzHaHfQmGum+KeyV+oj/ssiMA/TNaaPtnv+MnWPfeiLfnX3NtApRj5obkog3x4v4ooItcjsHSx44sPyfHJRPNCTef+Dg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785876358; c=relaxed/simple; bh=p2hL1KmPuqgpzwu8jtruJ3j9pIGD/r7WuE+EXQfFu30=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XOlOjk1xsn9IIL1r4CjSk7mphJqB6Chtf2zxddw/zhnVaZjuP1UDTctpgxMgl6w4Gd6On7EetNEcR2fFw48jYWS3f9ZOqFYMRrDVW5AA5W8NCAGiYWfpbcdjbD+dA7adUAXBRvQ+o66CQxexhoek4obh2tS1zv6MgKm49OThj70= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SBZlitvg; arc=none smtp.client-ip=209.85.161.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SBZlitvg" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-6ae88f4e4f4so192937eaf.0 for ; Tue, 04 Aug 2026 13:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1785876351; x=1786481151; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=qaL6InyMRx3887cIgsi7UMEZhQ8AgbGemHIp8YVHGfg=; b=SBZlitvgwtD9n12tFzRH5M5X9iWOBomJ2g74ONM/CdCN11VTVggeNPNixMDM2Cc+pw iEagCasqNA+7S86VAc7xWMmcy032+aMOXkZAqE4vZAVXsF3yA+u9i2H2Ur6Cl5zGpl6E r3SmS0Yp9RP9Qu+9gGYoDgb0h7ih52g0XZasg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785876351; x=1786481151; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qaL6InyMRx3887cIgsi7UMEZhQ8AgbGemHIp8YVHGfg=; b=Hi8Fa4PHe3vAi7oLJt/eEnqiA5A0hfoO2gebsP2BSlwb4KuIn5Ui3YEiQs0hKcPwkt JBfySkRqwbgSTA2XrFJcpxbR++NafkMJi7UQ/CyZVpRAiKwxbyJnFBLgjQX7nWz+xLWv yzxW7jCgUMILQRtfzynMrj9RBgM2QRHX84Pv+2FRMU0ayz0pNdFn0EWy8wYtWSkQGfl/ hpzQayinTJ0YJdyx7uBe0jd+DvnKT6uXysh07b3Ia6p91NV5guKEjKYEZvAd68qHhyOL QSSVlydI8Qqn5Hh2Xph9CgP9rQpLcqrFzB7t4yqlw0Vrda3VZOh0t3Nul4HEWXirSGKx xE/A== X-Forwarded-Encrypted: i=1; AHgh+Rq6DTv/V8VAQJ8a8t9Ct0weNx+1rU/x7LiyZus9HWJ6Jk3oT6sVqLjUr6DmahTPb8cHvUIRXCY06X1mUQw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9W9MqtcD8qzq44Dz0Xb++08Bnzk2Qe9t1PeG5iccXjjwZdY9S X4YDlC8OJTycp0BpWDxtazAIJvqS9ClpRBbkgAMMMNbRrMFD2HEHRi9XoimSVoCDkoc= X-Gm-Gg: AR+sD119vUkmTXVesNoi4YzmAvCrqIboPTQ0ylyukAqSUKkqXyZuxN8IrfITz2zvI3F RtaidY1e96uds2PfCTAeUw9zVlJZSfRw9+jeQEu5YTSO+pDNzhKbewugvDAu/OYnt/lvjwU2JHI fsINkJK29dSymOpIh8wwUFuiuvuIqj71NZCbpx8PHZ8nyH4L0UUPUJMMNnuDbKCNDn3H9tkPm8+ iAHeu/pEnI61Ct+EkWyOtCuKTr2rDAHO8B21VbBVJEt2OzAcsFI3siob7za1j9VHvqgQvtdGzQ0 F6FxJ5gD5Ih0D0oloXG3thpXALE+OTQowv08Gio/DzYB7i0iKLxH05Tl8NTrqEwKnORGo5uU6+q BSfNSqI82tb59anYxRtv9S4TrL74vvUi/Jy5hojevyFQdwWg4xPB1GmJY3oheW/l4FYWB/nArz3 r2ZQMvWxSckPtcji4e8BEr6hWjg0PLo2IUZa3seIB6tK/xx7e/0Ffh2g73pwxnb2HJs8tS9g== X-Received: by 2002:a05:6820:1c89:b0:6ae:4ff6:8d99 with SMTP id 006d021491bc7-6ae96f658cemr1057525eaf.26.1785876350998; Tue, 04 Aug 2026 13:45:50 -0700 (PDT) Received: from [192.168.1.128] ([38.15.57.99]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6ae93d61482sm817337eaf.7.2026.08.04.13.45.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Aug 2026 13:45:50 -0700 (PDT) Message-ID: Date: Tue, 4 Aug 2026 14:45:48 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/2] cpupower: fix topology array handling To: Ali Ahmet Memis , Thomas Renninger , Shuah Khan , "John B . Wyatt IV" , John Kacur Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20260803175215.117518-1-ali@iusegentoo.com> Content-Language: en-US From: Shuah Khan In-Reply-To: <20260803175215.117518-1-ali@iusegentoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/3/26 11:52, Ali Ahmet Memis wrote: > v1 did two things in one patch. Shuah asked for them to be split, so here > they are as two. > > Patch 1 is the uninitialized read: get_cpu_topology() allocates core_info > with malloc(), several paths never write core_cpu_list, and the sort > comparator then hands that buffer to strcmp(). calloc() fixes it. I agree that core_cpu_list isn't initialized and that needs fixing. It can be done with your first patch that replaces malloc() with calloc(). This code path can be improved to initialize core_cpu_list. Did you think about a scenario when the following check will be tru - i.e core == -1 is trur? if (cpu_top->core_info[cpu].core == -1) { strncpy(cpu_top->core_info[cpu].core_cpu_list, "-1", CPULIST_BUFFER); continue; } > > Patch 2 is separate and only about the physical core count. The counting > loop seeds cores at 1 from entry 0 without checking whether that entry has > usable topology data, so an incomplete entry can be counted as a core. > Patch 2 depends on patch 1, since it uses an empty core_cpu_list to > recognise an entry that was never filled in. Can you elaborate on a real scenario where this could happen after replacing malloc() with calloc() and making sure core_cpu_list is initialized to "-1" like in the above conditional? thanks, -- Shuah