From patchwork Mon Mar 4 11:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 778195 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 A7A2537167 for ; Mon, 4 Mar 2024 11:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709551365; cv=none; b=eGACw6t5IIRyFJOZbxfYpyrg9KjzjWQk0VA0SQ02oSA8IZMi+CfQLwewbfu9cML5QDrXHWwJGmdBZYcl0WiENZciBDfupmRoBFOlGwc5csGYdlBTwwxnuhObo6CFjetw2pw5wovtmqhJqtx6Wj3TRnBNbNAGzP3aBqUbKPwXRbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709551365; c=relaxed/simple; bh=4F/3pvoKPicmhJlfUvzEOvWzzDu4xBXOv6jna4p07u8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=SUlSwqAYRmUHNNW2hji2AFm03qXKYiK7nXqCG1YRuqi2H9CvwpGTmvBGMLWduCvWMErTVSUIopRhrc4YEY4pvMsGgJ4CitQ+syREAgEfCO1aQP8dJATTn0Nh0krfvxlEZrLLP3VuG3WeGE6s/j0rR0pbURZFv4jfdgNk3XYxjHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Jna1ogaf; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Jna1ogaf" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6e5760eeb7aso3479784b3a.1 for ; Mon, 04 Mar 2024 03:22:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709551363; x=1710156163; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xfdTBXeEYKopzUYmugLEzbdirAWxeCvLjKk0bWULobA=; b=Jna1ogafl93NSLBHvs+lxS/585PJk+MolX5HJVQ0KDmwr5gthXGdR7hl6Y6lUKjiOw P1Sky7q+5GNnM/owmUYkYQ315iEestDtWBBtdhICnkrELW/Fm2yQ7THz+GOKCFSudARi LviE1q/GAo7NigqAPzYTCbCFciJAVKLPKGaFV+W0NDEIUxvckeI6p6Gqjo02fp7MoAQI k58kbv7wV61ALc0+Y/cq6/hmmHuK0FPKxBbcUtitJaluKXJAo00aR4N5mqAY3iz1ZNMy PBHEvuQmqJFNuQkOTQHK5acFBkqgO9cJtc6Rd3w6ncNH6EiT2LBrdpjkscG6Ab57UnzE Cmjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709551363; x=1710156163; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xfdTBXeEYKopzUYmugLEzbdirAWxeCvLjKk0bWULobA=; b=gGRptGe3+LjPOCeSTwEJyH72OtJ6a6DLXgVyrtIxYNyydypfEXucCaRVFBiCa4hFQY B9SmTljnV9FQWgQOLKPp8raUzDBO30aKBSEUrTNRsD47xGf7k8qc618HrO6Y1J0x5vkl o+8cqkBQEAFTbqqSeo/gFUyXtiAybM6j8DAyhRV9MkESQpEJGssiEke0Ar5L4B4/Fx/5 5miR11ErPPOQd7Y4MXA7N+9DVa4SMAR9gGvRY1R0T3Pu2tVSyNvoyZnvRGrX3BCKFESQ +s1TKSBFp+7HSGQeKiWASEuVzCeRJ6t81ke/3YYqWvEygD4KTEQZjGbxNgfpHRibuoaX XTDg== X-Forwarded-Encrypted: i=1; AJvYcCUgDnWH//iFMswHBkswvZ0hiH693R1i3gks1MmZJya1stNuLLiis3rogXvfeCXtM2+VfzgJah2r7BDlKhteA7GONBQ2+3kJ2Ik= X-Gm-Message-State: AOJu0YykBtTy+D+wKCg4CbcNBUYUBa0Kw2Kt1zh4NGZXJdIRXOCpkIkX 5s7+8ByoUTR0lSAqeTkytUDSdMkp+yllayTBfCyBN7wsAaGCLJD4l6RLkzeMysc= X-Google-Smtp-Source: AGHT+IHqFMWOfl9tVFl2Amp3r1hgjAKb7v8stgiiurB0hYbr37gSBL/VdKul0V4K6tiB9sapT0BOhA== X-Received: by 2002:a05:6a21:339f:b0:1a0:f4d2:31ab with SMTP id yy31-20020a056a21339f00b001a0f4d231abmr11208495pzb.19.1709551363016; Mon, 04 Mar 2024 03:22:43 -0800 (PST) Received: from localhost ([122.172.85.206]) by smtp.gmail.com with ESMTPSA id x14-20020a056a00188e00b006e55f6cd7fesm6968031pfh.137.2024.03.04.03.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 03:22:42 -0800 (PST) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Dhruva Gole , kernel test robot , linux-kernel@vger.kernel.org Subject: [PATCH V2 1/2] OPP: debugfs: Fix warning with W=1 builds Date: Mon, 4 Mar 2024 16:52:38 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We currently get the following warning: debugfs.c:105:54: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=] snprintf(name, sizeof(name), "supply-%d", i); ^~ debugfs.c:105:46: note: directive argument in the range [-2147483644, 2147483646] snprintf(name, sizeof(name), "supply-%d", i); ^~~~~~~~~~~ debugfs.c:105:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15 snprintf(name, sizeof(name), "supply-%d", i); Fix this and another potential issues it by allocating larger arrays. Use the exact string format to allocate the arrays without getting into these issues again. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402141313.81ltVF5g-lkp@intel.com/ Signed-off-by: Viresh Kumar --- V2: Use string name while allocating memory for the array to fix potential issues later on. drivers/opp/debugfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c index ec030b19164a..27c3748347af 100644 --- a/drivers/opp/debugfs.c +++ b/drivers/opp/debugfs.c @@ -56,11 +56,11 @@ static void opp_debug_create_bw(struct dev_pm_opp *opp, struct dentry *pdentry) { struct dentry *d; - char name[20]; + char name[] = "icc-path-XXXXXXXXXX"; /* Integers can take 10 chars max */ int i; for (i = 0; i < opp_table->path_count; i++) { - snprintf(name, sizeof(name), "icc-path-%.1d", i); + snprintf(name, sizeof(name), "icc-path-%d", i); /* Create per-path directory */ d = debugfs_create_dir(name, pdentry); @@ -78,7 +78,7 @@ static void opp_debug_create_clks(struct dev_pm_opp *opp, struct opp_table *opp_table, struct dentry *pdentry) { - char name[12]; + char name[] = "rate_hz_XXXXXXXXXX"; /* Integers can take 10 chars max */ int i; if (opp_table->clk_count == 1) { @@ -100,7 +100,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp, int i; for (i = 0; i < opp_table->regulator_count; i++) { - char name[15]; + char name[] = "supply-XXXXXXXXXX"; /* Integers can take 10 chars max */ snprintf(name, sizeof(name), "supply-%d", i); From patchwork Mon Mar 4 11:22:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 777920 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 054903984B for ; Mon, 4 Mar 2024 11:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709551368; cv=none; b=g5RkRVKbGAp8XUrkTCmbOhqa4iXh4QKe19oXZ0iprF1UBrbraqVyvYL6pXJ+bmmyyarFZQ5/7upDpstdTv0l3gaS7fY7V1ATIJSdzi1g0rt9cfWHv0hpMZaYzdLLRR/8r0cXgKcqkSsXO1OLMddIDIpGL4mzN+gOvBZLyJG/M6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709551368; c=relaxed/simple; bh=Am+c6dBF6BHH2/RgeyDCuH3cl4jzRaTZllBvX4joDU4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fVox+TfLJD7olk7FW6ucmSFyptoH17jfQ8FTdqpBZ9YtI3veY4+CSsZ91dv8TQRhCRBX2e0B5+Ru2Ut4gK2mUrGVaC6KXY2oi+DXtvo19i0y075gL1gkg7bc69gBovmQQiokHZtDYBVLN3rhJ1UP05BkHDQXjOwnJ0a2AXD96wc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=d4HGey8N; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="d4HGey8N" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1dcab44747bso34884315ad.1 for ; Mon, 04 Mar 2024 03:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709551366; x=1710156166; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0o2qbRz2LsYMldaZB2Fall4oN2xIZEAZu8iTzW+0lNA=; b=d4HGey8N+RGJYYXIsf1LaNUWUyVqK0xKAYAV6olhhD1fzviqRu1nR4cG7lkpWm74ob EqyuV9WuZNDlcVlTEkWzRmdGRCDI+7hr5RBjAl3/5+UlsaO8+B1wC+msVbmzjvGSFUVS twfv/wd0t5Koy5gzg6SThA6SZGH0vlHNZAoivQHlF85XtG4IMyD5Nti7iD3UZb3gsGiI zAGAgetOvA9Z6fNsCovyH8j0gvwGMav0lsC94uoLppQwCoUDnhWvIc4Y7ZBOkRoO/aCh coG2AUVujbilniFtEZ17IHy2CZBazl8po/hKgOpJmVPn42mAkSXXhoOKC3EojeLtJpIX o2bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709551366; x=1710156166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0o2qbRz2LsYMldaZB2Fall4oN2xIZEAZu8iTzW+0lNA=; b=uflLe2dnGMYFn+RVw3lD4xFdBMVOqfyjEBPkzKAS10Yv9Q19+K0iye1unUPfm04I1q HPdhDID/6XOQvAYfiTRvm3ED28nm1fFlTsSJXrjUPGLWHISV+GGGGy05qxydx5BVyvV9 6sKD+cG22R3JTK4zOCw+XQhvQNEbDG3slJEpDsFZaFv/CmKLA87dl4igZnwqgshRud7Q wtIGAfJ/gAzE0TWSCWu/iOPnacn1tZ1e/2mcc7xYK4XAJXLzOyOwUdb0boFwWfcLm7ro rck7XETIM8Edi8tN4iy12HypVwfkDhNu8a7z8koS3T3rd1tyJu/dYZ4hflCY/YyjNE02 szHA== X-Forwarded-Encrypted: i=1; AJvYcCXCr3SMcD4ZcIL9unfYmzhcL2RdbiAKRLQzmkTFU7HBFZYAlzu46+pj74ChQMAOU4eAFoGv8WUXiudqAhZhtWSMLyyNWG7gpEw= X-Gm-Message-State: AOJu0Yx9W4ETnrm3zXN0QQ51aSjRVY+BxN8U1Mm59bfZr0aad1aVx3Ox NOeN7MeWId3ObH1YJnfXhiPVBYdlGslHXZHVeokRZItkEX6ySescTk5g/T3O19E= X-Google-Smtp-Source: AGHT+IHz7bqsB9Ws8NUy0LKb8krVg7wj1/42xJsEwwY/wamQqVtxqvyzRSdaS0/cjmA8YPFhGCsXCA== X-Received: by 2002:a17:902:e78c:b0:1dc:fc86:2e7a with SMTP id cp12-20020a170902e78c00b001dcfc862e7amr5384513plb.59.1709551366086; Mon, 04 Mar 2024 03:22:46 -0800 (PST) Received: from localhost ([122.172.85.206]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001dc11f90512sm8225480plh.126.2024.03.04.03.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 03:22:45 -0800 (PST) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Dhruva Gole , kernel test robot , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] OPP: debugfs: Fix warning around icc_get_name() Date: Mon, 4 Mar 2024 16:52:39 +0530 Message-Id: <0275dc46489419f34765c6ed389c0e9d6245fd31.1709551295.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If the kernel isn't built with interconnect support, icc_get_name() returns NULL and we get following warning: drivers/opp/debugfs.c: In function 'bw_name_read': drivers/opp/debugfs.c:43:42: error: '%.62s' directive argument is null [-Werror=format-overflow=] i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path)); Fix it. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402141313.81ltVF5g-lkp@intel.com/ Signed-off-by: Viresh Kumar Reviewed-by: Dhruva Gole --- drivers/opp/debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c index 27c3748347af..a9ebfdf0b6a1 100644 --- a/drivers/opp/debugfs.c +++ b/drivers/opp/debugfs.c @@ -37,10 +37,12 @@ static ssize_t bw_name_read(struct file *fp, char __user *userbuf, size_t count, loff_t *ppos) { struct icc_path *path = fp->private_data; + const char *name = icc_get_name(path); char buf[64]; - int i; + int i = 0; - i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path)); + if (name) + i = scnprintf(buf, sizeof(buf), "%.62s\n", name); return simple_read_from_buffer(userbuf, count, ppos, buf, i); }