From patchwork Mon Feb 24 17:33:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13988609 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 438D3264A8B; Mon, 24 Feb 2025 17:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418489; cv=none; b=PNQJKqIO6VBqJnzxLu9USi7qBHv4Z2NyroFZifgaaO2SSdG1O0TdLx1tfUROXZtORHHwXdFs4uFNrIRMul52Quisp8ZcXDGmf20LJngiZRV0VoXbXr47NVUxXp6DvIBMadmxUCpRNVT9hiQiqZRWZ3Oi0ZiWPWlNMVpiMRvuIQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418489; c=relaxed/simple; bh=I++dDYsKJnAzZs7TT3zrtUksPHsTx63cS2lKz5ZMiDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qax8lIDgvhvKzpmXAt+ZsP7uADP9TGiOTB/6J/EJY3cY7TQB56UZJm/tH/khriiizGW6uALhBrCqAg5wW7mjItqV+6QD/FL/1M3qJY6W7sm+h1Y/lFVBCGwcaveTCD95kGFQ6v9MZN2b/Pxlz8wCOAW0PvIKY9aAbUEb/cAaOTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 342CE1756; Mon, 24 Feb 2025 09:35:04 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.65.109]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CF1B63F5A1; Mon, 24 Feb 2025 09:34:45 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org Cc: lukasz.luba@arm.com, rui.zhang@intel.com, srinivas.pandruvada@linux.intel.com Subject: [PATCH 1/4] thermal: OF: Use kcalloc() instead of kzalloc() with multiplication Date: Mon, 24 Feb 2025 17:33:03 +0000 Message-ID: <20250224173432.1946070-2-lukasz.luba@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250224173432.1946070-1-lukasz.luba@arm.com> References: <20250224173432.1946070-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 According to the latest recommendations, kcalloc() should be used instead of kzalloc() with multiplication (which might overflow). Switch to this new scheme and use more safe kcalloc(). No functional impact changes. Signed-off-by: Lukasz Luba --- drivers/thermal/thermal_of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 5ab4ce4daaebd..fb376bd4d9579 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -107,7 +107,7 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n if (!count) return NULL; - struct thermal_trip *tt __free(kfree) = kzalloc(sizeof(*tt) * count, GFP_KERNEL); + struct thermal_trip *tt __free(kfree) = kcalloc(count, sizeof(*tt), GFP_KERNEL); if (!tt) return ERR_PTR(-ENOMEM); From patchwork Mon Feb 24 17:33:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13988610 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D1CA265630; Mon, 24 Feb 2025 17:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418491; cv=none; b=YWndDKk7WdGJIWczSdoB7lUaFmvpgrXHnuFkB63XQYJDLkyCo3SedmPIb3LlstprCIJuNUfc6LGZtL4Xzz1gpJo+axSREvRcVnzLWCKmfVkKPI+LHS6XusDxJ/VEtkt+ssgGL2V38SQthvOa3d2Mf880VuA8CuEoNUh5Af+fXt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418491; c=relaxed/simple; bh=b+5bekHFm+sDW6aHnNsKja9uTB5ioANecssh2KfE3IY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rx1Nqbv8HYDwyEZ9IjFcNuk0/4nfx/5ZoXjjA/jiRTBuAIvX2F55zwJ6HlEJlG61SCer4Zn0UsBs2cHPkfKDd8WBS1L/TAp19Hcho2sJRo6Udg+vy4bxcvfayP0jFAeZhaGewRr1BZpZKaIkYWS1u1ROSf0SSo1LWRr2pjAXsc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 58003152B; Mon, 24 Feb 2025 09:35:06 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.65.109]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 001BA3F5A1; Mon, 24 Feb 2025 09:34:47 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org Cc: lukasz.luba@arm.com, rui.zhang@intel.com, srinivas.pandruvada@linux.intel.com Subject: [PATCH 2/4] thermal: k3_j72xx_bandgap: Use kcalloc() instead of kzalloc() Date: Mon, 24 Feb 2025 17:33:04 +0000 Message-ID: <20250224173432.1946070-3-lukasz.luba@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250224173432.1946070-1-lukasz.luba@arm.com> References: <20250224173432.1946070-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 According to the latest recommendations, kcalloc() should be used instead of kzalloc() with multiplication (which might overflow). Switch to this new scheme and use more safe kcalloc(). No functional impact changes. Signed-off-by: Lukasz Luba --- drivers/thermal/k3_j72xx_bandgap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/k3_j72xx_bandgap.c b/drivers/thermal/k3_j72xx_bandgap.c index 70de6dbf99c5a..a36289e61315a 100644 --- a/drivers/thermal/k3_j72xx_bandgap.c +++ b/drivers/thermal/k3_j72xx_bandgap.c @@ -460,13 +460,13 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev) goto err_alloc; } - ref_table = kzalloc(sizeof(*ref_table) * TABLE_SIZE, GFP_KERNEL); + ref_table = kcalloc(TABLE_SIZE, sizeof(*ref_table), GFP_KERNEL); if (!ref_table) { ret = -ENOMEM; goto err_alloc; } - derived_table = devm_kzalloc(bgp->dev, sizeof(*derived_table) * TABLE_SIZE, + derived_table = devm_kcalloc(bgp->dev, TABLE_SIZE, sizeof(*derived_table), GFP_KERNEL); if (!derived_table) { ret = -ENOMEM; From patchwork Mon Feb 24 17:33:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13988612 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73963265CD3; Mon, 24 Feb 2025 17:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418497; cv=none; b=AcRfU6GYdKIJRhfKnzeJvq8dN59BwtLlD25C1LsyXabUn3tTQw1fG8bZkwZ33c8Qva3eJOIoX3908JzuBGfdgf0zJ0e6nLLC9oJQOIhEksqzPfC+bIhHHx8Ov+vuVRsDZT5Q9fAgDKKmXUQ8hZUzjG3HIxiZNVxBqC3eoEc7Jag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418497; c=relaxed/simple; bh=4FN3Kso8IEB/8nRwPwS1e0s0rSpmccUC6yRgfCqU3tI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iyuKbzwAjyxPzZbPtrdi/HPCkZY1z3fsl+m7RtpClDw237NSX7gwhWG0vipcrhEE2GswkT9dw8fYE1ZfEeWm2AC63qq+0racZ9/w4qrci2Ef39R/PL9dFbXkDJXQkZTE9DsTFKyC8UBsykBJFz/Zjn1G7FdM0hmBvMpfNuSkruA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 7DF63152B; Mon, 24 Feb 2025 09:35:08 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.65.109]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 242AB3F5A1; Mon, 24 Feb 2025 09:34:49 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org Cc: lukasz.luba@arm.com, rui.zhang@intel.com, srinivas.pandruvada@linux.intel.com Subject: [PATCH 3/4] thermal: int340x: Use kcalloc() instead of kzalloc() with multiplication Date: Mon, 24 Feb 2025 17:33:05 +0000 Message-ID: <20250224173432.1946070-4-lukasz.luba@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250224173432.1946070-1-lukasz.luba@arm.com> References: <20250224173432.1946070-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 According to the latest recommendations, kcalloc() should be used instead of kzalloc() with multiplication (which might overflow). Switch to this new scheme and use more safe kcalloc(). No functional impact changes. Signed-off-by: Lukasz Luba --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 8dca6a6aceca1..2d672c4be3ce5 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -133,8 +133,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, if (ACPI_SUCCESS(status)) int34x_zone->aux_trip_nr = trip_cnt; - zone_trips = kzalloc(sizeof(*zone_trips) * (trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT), - GFP_KERNEL); + zone_trips = kcalloc(trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT, + sizeof(*zone_trips), GFP_KERNEL); if (!zone_trips) { ret = -ENOMEM; goto err_trips_alloc; From patchwork Mon Feb 24 17:33:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13988611 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A12A2264A88; Mon, 24 Feb 2025 17:34:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418496; cv=none; b=g8yK/OYXuudx/x/1AZ3fs1+LgUjeppTMt4nVqtI5idvCtlzGRLsNgdoAIv39SzbRZMk0ebqgR/69HcCR2Le/IiES/QrMdRw+MUpIl3H023P1r/dAwvwWt4jK5PwrofPbb9zhN/KT1Wk8ukUsAZxHZY9MLIAxqQRtkEcGuxJ5H1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740418496; c=relaxed/simple; bh=b5ZVC40DDyXz6JHdlPQVXaMyUJ8Y1KOTGrt2hfJI5z0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MBMnquIN9TGHclC4kcnZzwFaFjeWTFMPjHWEb8CIJc0SEPc3M52S4eE1/pH0gI0E9hasiEE46HvUlAzDEM5ZbU4A1B5+LjWkJM80zOn0x0hls9yJyV53Azr+eTk6ECA4ninWU5sA/fbyWcLX/+E05g4TzLmHDR7PFMLvJD54GP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 9E56F1756; Mon, 24 Feb 2025 09:35:10 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.65.109]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 471893F5A1; Mon, 24 Feb 2025 09:34:52 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org Cc: lukasz.luba@arm.com, rui.zhang@intel.com, srinivas.pandruvada@linux.intel.com Subject: [PATCH 4/4] thermal: hisi: Use kcalloc() instead of kzalloc() with multiplication Date: Mon, 24 Feb 2025 17:33:06 +0000 Message-ID: <20250224173432.1946070-5-lukasz.luba@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250224173432.1946070-1-lukasz.luba@arm.com> References: <20250224173432.1946070-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 According to the latest recommendations, kcalloc() should be used instead of kzalloc() with multiplication (which might overflow). Switch to this new scheme and use more safe kcalloc(). No functional impact changes. Signed-off-by: Lukasz Luba --- drivers/thermal/hisi_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 7e918bd3f1002..4307161533a78 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -412,8 +412,8 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) data->nr_sensors = 1; - data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) * - data->nr_sensors, GFP_KERNEL); + data->sensor = devm_kcalloc(dev, data->nr_sensors, + sizeof(*data->sensor), GFP_KERNEL); if (!data->sensor) return -ENOMEM;