From patchwork Tue Feb 13 09:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 200327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp437919dyb; Tue, 13 Feb 2024 02:09:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrX8pzCDCkOMcSFYkzIVKcsQyWGSYC7VkE3h5M3C+aW6WeEDE4ouwKtH+6Iv4+RhJixuR6 X-Received: by 2002:a05:6a00:1988:b0:6e0:4b81:907b with SMTP id d8-20020a056a00198800b006e04b81907bmr2887162pfl.10.1707818960649; Tue, 13 Feb 2024 02:09:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707818960; cv=pass; d=google.com; s=arc-20160816; b=WvhKvKd56M52k+N7Spx0HDVQ3TBbNvVmUfbDFCKjYAs1g/t/eYgqWCQKmdJoU7gavj PjycYYS3wNK0UpxzVuBkH4KFluLhiD/7iZ2mn0Na0bkeZAMj+ZS5pWM+h0pA4sUjXiCo RMvvpoOctkYqwDzf/EMCXh/v5+Zm8qb/Gv5EtQOOrRlnkGeWL+NsvixiWRt2f4FWNwJO BPocPaDrpAAwJ30G0zeXNczQvLZoQq2wmfLER5JrTzl329QsifhWckCnEvjYiaH6sDQw LNqjbyHS80EZ85NXoZ61odrLgsu+O0nV3pFKKdDSMG9i8KfAB7ByD6uhzP0bt9pnT4af n7tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=KTerp5HT+idSBqJrLaS8vYAD0Y7JjuxhMyXb9HEVw28=; fh=g/GHuGhYHrFQa3AVF32OYfMraYpHJkcghjuC9FEpXaQ=; b=DfKuJbmJgfl8wzZvv40zBcAVJsqblCWFT/FkhO3ub12mkqDSKIjxUj7XLB5hLKiGg7 G8z6L4NumSRcBvAYdznspRflgcqxm8MSMzL860AHkneuLAPl+8qb+ADRDsGhEc1PSd7i WjyqBjp+RTrpNSyVdl30Da8E+GE2vqZ786MOZU7q+q9oMAEuCmSa03josvHUnVZeOxry oc9THRSrnq8C5/B/cfYISrGxLzracEQVbPWG639YTT7dY8B1GNEmxu5gNKqJQdFK72nJ CUS7blUUNGQERClV6wKOK7t6sEyjY5Vynq0QFwhoXKkhyN+iI8Y7AbY0MKW4EFcqiI3m XauQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=C0FgHTg+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=YW9SSPF1; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-63282-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63282-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCVjyGsgvc4KqtnCRQPnNUtDQ9Sq382BMaCfE0ftJY3yGylraC58doblvzVUdEVginUxg92zYXIjyaL9WF0wf2adCVbCEA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j10-20020a056a00234a00b006e09499cc7csi6611171pfj.183.2024.02.13.02.09.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 02:09:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63282-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=C0FgHTg+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=YW9SSPF1; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-63282-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63282-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D9233284C91 for ; Tue, 13 Feb 2024 09:58:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60738383B2; Tue, 13 Feb 2024 09:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="C0FgHTg+"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YW9SSPF1" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C647A2C689; Tue, 13 Feb 2024 09:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707818223; cv=none; b=Y/Vs7T59cjPaN4+YmAFM43iivsRMcCVnQFm0mz54WupRjoZyAsQEcXJcGoBstEvi4rRuk2/WvuTL6C97STMH56QWdW1ntd7hAabWoBZNE8kfnHEXUfwnNj1vPk8lvT0rf5X0nT3nYPfmbVHpNBHky7JrZpsO+G/4yni4LUNNppg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707818223; c=relaxed/simple; bh=mTaDyVMtRZwxa9j2lHhhogsZ7zwCVB9IpyeNRMzoUr0=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=txnrAmDG3nbA4bWPvrq6nuLxgWcRUTQdgBOLgkJOSNX1028nNZ0oZkHJApsJ0JldEbikBmL4S1qhRXyFp9W3/mgMTVxgxhnJ3TtUWbpc0SnYsNl5r/T/Lm9sEdvhDfZgRD7mLKmjxjCnO6L14lM4LNaQHC1FoAGP1VFRLSZWrwo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=C0FgHTg+; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YW9SSPF1; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 13 Feb 2024 09:56:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707818219; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KTerp5HT+idSBqJrLaS8vYAD0Y7JjuxhMyXb9HEVw28=; b=C0FgHTg+ZP+8PYYc4GGQUku5NsLqQHER8qUANLJn3IyRFSf1RjqkGLy33sg+wcwQ8FO75M 7FjF7al0g2vOJe/sv3UqZ1pts8LoAyPsViNt6zq17QiJfZ2uRkbOwwRlj+upivY3INgxVw d7UTrBM0LmSchEMn9w41na9rQaeP7CP6ovPP4OFD1Ur7E6GjWPAOJdjn2qzkCyn0ftL05h 7MGy9bCWEg6JOHHlN2hSPUgntvFhdKg056VY+Goqesf3T+hS0Iv1J7WUdhzQtBlUmGuRnp sXpc5VIVB67GKkQMNFPJHeb7yEIqmvupPas+3LHKb035+UIzkl46VyR0kvgdRg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707818219; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KTerp5HT+idSBqJrLaS8vYAD0Y7JjuxhMyXb9HEVw28=; b=YW9SSPF1RC56iIkZdLFgFAU7OqFgqqLXyiu7QElYyh+J3mx3l04Q1CNS+RqGG8A7de3t79 IxrelQzehv4QpuDw== From: "tip-bot2 for Erick Archer" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/bcm-6345-l1: Prefer struct_size)_ over open coded arithmetic Cc: Erick Archer , Thomas Gleixner , "Gustavo A. R. Silva" , Kees Cook , Florian Fainelli , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20240209181600.9472-1-erick.archer@gmx.com> References: <20240209181600.9472-1-erick.archer@gmx.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170781821908.398.371290728146239013.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790777974525242086 X-GMAIL-MSGID: 1790777974525242086 The following commit has been merged into the irq/core branch of tip: Commit-ID: 004c7a6bf43edbd4b092fb6ebba8991d56bc3428 Gitweb: https://git.kernel.org/tip/004c7a6bf43edbd4b092fb6ebba8991d56bc3428 Author: Erick Archer AuthorDate: Fri, 09 Feb 2024 19:16:00 +01:00 Committer: Thomas Gleixner CommitterDate: Tue, 13 Feb 2024 10:53:15 +01:00 irqchip/bcm-6345-l1: Prefer struct_size)_ over open coded arithmetic This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows. The cpu variable is a pointer to "struct bcm6345_l1_cpu" and this structure ends in a flexible array: struct bcm6345_l1_cpu { [...] u32 enable_cache[]; }; The preferred way in the kernel is to use the struct_size() helper to do the arithmetic instead of the argument "size + count * size" in the kzalloc() function. This way, the code is more readable and safer. Signed-off-by: Erick Archer Signed-off-by: Thomas Gleixner Reviewed-by: Gustavo A. R. Silva Reviewed-by: Kees Cook Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20240209181600.9472-1-erick.archer@gmx.com Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 [2] --- drivers/irqchip/irq-bcm6345-l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-bcm6345-l1.c b/drivers/irqchip/irq-bcm6345-l1.c index 9745a11..eb02d20 100644 --- a/drivers/irqchip/irq-bcm6345-l1.c +++ b/drivers/irqchip/irq-bcm6345-l1.c @@ -242,7 +242,7 @@ static int __init bcm6345_l1_init_one(struct device_node *dn, else if (intc->n_words != n_words) return -EINVAL; - cpu = intc->cpus[idx] = kzalloc(sizeof(*cpu) + n_words * sizeof(u32), + cpu = intc->cpus[idx] = kzalloc(struct_size(cpu, enable_cache, n_words), GFP_KERNEL); if (!cpu) return -ENOMEM;