Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp2890147lfb; Thu, 23 Jun 2022 14:15:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLhT7etsUr8Pczk6a4MXkjAxiLMBByq8BP7vay8sH3yf94giulNc7DXCDJ9OYkV/HBtbNl X-Received: by 2002:a17:906:3f51:b0:712:3945:8c0d with SMTP id f17-20020a1709063f5100b0071239458c0dmr9974245ejj.302.1656018920881; Thu, 23 Jun 2022 14:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656018920; cv=none; d=google.com; s=arc-20160816; b=UtD5cJTF/+fsikx0jXeMNUU76PvPRRi45qgy3EePKT8DDVHVq+aB5dy1PEMIAHTjgJ zyBUSlzXT6YkVmLltnnxePE1pVMT3N+b7JmVQSkPXz6bDB//BfstccyZveaVSh7HZ54d XwPU7D4Lt4YBi/gkGBsXYpla0+mrOkwA+Q+g4hQDG1M2n7UD/mEuNEfjQXJP4u14aaex AifV99MvTU8m0zIkEcGVZ4dtHx01SsvUkUwfXBG5c0LVQ0F381W40e5Hw6h9+QvcwS6e 5ObbozRj13vClNZRDFx+blsq+DcLtjfvKgYeqBHN0UA0BmvxwnvmcLUOU4PjxR/A9Fz5 Xm9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7iiZ1g2foyg+pIBZL+lLC+0n9kDHXAVzLQyCSVfDJ08=; b=D64pfpJNtUJZ06RbFskUz69gGq0/IOoVOYSfOqVMDZ4ENv2UinKq4fTc1H+tlwrjF3 lTKp6wPqT1ULTT57XqksOBlyQFISECWXb2IvjUD6yBWmLOo7qwqrkTuK8hD+IQXnGnGr Br7C+ynTtve54i6+dM3YnUNBJTpz9J7oLoBE3X43hPvZhDrw51OYFPeqfK+lfHxOc4V6 N54Zt3/0dtlxOb6lbFeuS3iabY5T89+MzVTCXR9Tg9fJBRBDxDIxGg7tzc32aE8soKsP yiKB5zs97ilJ2xnlSImB+cwNHwNYSTYd9ypsLW+NzsmcFnvmnOpisLm59ykEAvErC5kD SE7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g4Grn3Ym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb9-20020a170907960900b007152a3ee4easi216715ejc.664.2022.06.23.14.14.56; Thu, 23 Jun 2022 14:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g4Grn3Ym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiFWVNj (ORCPT + 99 others); Thu, 23 Jun 2022 17:13:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbiFWVNc (ORCPT ); Thu, 23 Jun 2022 17:13:32 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5731F506E0 for ; Thu, 23 Jun 2022 14:13:31 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id r20so547593wra.1 for ; Thu, 23 Jun 2022 14:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7iiZ1g2foyg+pIBZL+lLC+0n9kDHXAVzLQyCSVfDJ08=; b=g4Grn3YmGC1+IcwN8QObevjbd44d+989zZV+3JaTY0xt8f1ITTyHLY15SH3o3Pclfo jYDv4Vr7GOSZ05ufB0Br/B8EHSblAJr/fkGVc72codtkMdE1zq9PJbCd6sodW2TQSLum osZmiOCWEG6jhR3R0gbVnM4Izz2BwSG0aFlC+jqlPGEbGTFX/8j6HmecQ5jEumqbInp8 sKZV22XFx1wYMMOAZMGgs+U351HVh/hct3l5X6lwd8hD8vS2MF+O2WY+nfspmYPLTxy7 TD5hml3FtevOv1YsGFALikrAqkz1NrpKtR1VCfoejqakoB6HkBwfMAlJVNRI/aA36gXf 9kLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7iiZ1g2foyg+pIBZL+lLC+0n9kDHXAVzLQyCSVfDJ08=; b=R+wTkg3D3gz5jPhO5voJBfuDgKwps2faq89fn1nhTN4EFO0J7QMlO0rIiGf3ggIGNW IWOOgBXn/t9LdFlHtzz9bdXmALs+qb3dcjvPqxhIUglgvCyaiUg30lrzgNk7msSQNgwJ Qps8TvThstsnloAhNdMtpYxjKoSKW7NLTQDrn8TzTqixi4u9wFIl30wuBPFH7nGwY67O +H26egCI2w5/H9Z3zXQ2aUZ+GvAMoyb3/H2C/rf3OYW/8N05b26RS2jyjgxsdWUnQKPP jpU2KBY6NmUJn+yFrI9bSqhkgnJCc1DuvRSwg06niGw4KMtQ/29syvBPTLR1S8Nb6c/l aQ/Q== X-Gm-Message-State: AJIora/gOOMo0Drcs1Mg0HFxc3gxOHDTF1upXvgPEQx3M1kLxCOKimSR Ljn7bJLWctvzCR9v5N3yCeY= X-Received: by 2002:adf:fa52:0:b0:21b:910d:cddd with SMTP id y18-20020adffa52000000b0021b910dcdddmr10192030wrr.291.1656018810933; Thu, 23 Jun 2022 14:13:30 -0700 (PDT) Received: from localhost (92.40.171.44.threembb.co.uk. [92.40.171.44]) by smtp.gmail.com with ESMTPSA id ay26-20020a5d6f1a000000b0021baf5e590dsm412186wrb.71.2022.06.23.14.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 14:13:30 -0700 (PDT) From: Aidan MacDonald To: broonie@kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, andy.shevchenko@gmail.com, mazziesaccount@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 03/12] regmap-irq: Cleanup sizeof(...) use in memory allocation Date: Thu, 23 Jun 2022 22:14:11 +0100 Message-Id: <20220623211420.918875-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220623211420.918875-1-aidanmacdonald.0x0@gmail.com> References: <20220623211420.918875-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of mentioning unsigned int directly, use a sizeof(...) involving the buffer we're allocating to ensure the types don't get out of sync. Signed-off-by: Aidan MacDonald --- drivers/base/regmap/regmap-irq.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 475a959e2b8b..dca27b4e29d3 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -670,30 +670,30 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, if (chip->num_main_regs) { d->main_status_buf = kcalloc(chip->num_main_regs, - sizeof(unsigned int), + sizeof(*d->main_status_buf), GFP_KERNEL); if (!d->main_status_buf) goto err_alloc; } - d->status_buf = kcalloc(chip->num_regs, sizeof(unsigned int), + d->status_buf = kcalloc(chip->num_regs, sizeof(*d->status_buf), GFP_KERNEL); if (!d->status_buf) goto err_alloc; - d->mask_buf = kcalloc(chip->num_regs, sizeof(unsigned int), + d->mask_buf = kcalloc(chip->num_regs, sizeof(*d->mask_buf), GFP_KERNEL); if (!d->mask_buf) goto err_alloc; - d->mask_buf_def = kcalloc(chip->num_regs, sizeof(unsigned int), + d->mask_buf_def = kcalloc(chip->num_regs, sizeof(*d->mask_buf_def), GFP_KERNEL); if (!d->mask_buf_def) goto err_alloc; if (chip->wake_base) { - d->wake_buf = kcalloc(chip->num_regs, sizeof(unsigned int), + d->wake_buf = kcalloc(chip->num_regs, sizeof(*d->wake_buf), GFP_KERNEL); if (!d->wake_buf) goto err_alloc; @@ -702,11 +702,11 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, num_type_reg = chip->type_in_mask ? chip->num_regs : chip->num_type_reg; if (num_type_reg) { d->type_buf_def = kcalloc(num_type_reg, - sizeof(unsigned int), GFP_KERNEL); + sizeof(*d->type_buf_def), GFP_KERNEL); if (!d->type_buf_def) goto err_alloc; - d->type_buf = kcalloc(num_type_reg, sizeof(unsigned int), + d->type_buf = kcalloc(num_type_reg, sizeof(*d->type_buf), GFP_KERNEL); if (!d->type_buf) goto err_alloc; @@ -723,7 +723,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, for (i = 0; i < chip->num_virt_regs; i++) { d->virt_buf[i] = kcalloc(chip->num_regs, - sizeof(unsigned int), + sizeof(**d->virt_buf), GFP_KERNEL); if (!d->virt_buf[i]) goto err_alloc; -- 2.35.1