Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp768277pxp; Fri, 11 Mar 2022 14:36:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0oGqNs0K4SrJPo4snM2SAvAkyjWkJZCm2dW1VddPVTWFKyX5R3XrgMoxCJs4210BmuUDv X-Received: by 2002:a17:90b:1648:b0:1bd:28ac:859d with SMTP id il8-20020a17090b164800b001bd28ac859dmr23674222pjb.59.1647038214206; Fri, 11 Mar 2022 14:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647038214; cv=none; d=google.com; s=arc-20160816; b=CiD6dimVIDW6mrHwDo4RikljXWzEb6jrcEWiRvf2MlC4X3bFThrFd1E97SZRbwv0T/ CXe0sjsC8nEDCq0KP7k/bU15ZLSfl1Xp1P9ZcVDTkxx4tqAg06lZxmzk116Rh/rUWZuo JQdMie5H2tU1zz1kzXXqOD4ycXzI5rZLH/fApArcf5yP1wyVSpfkJnnlkMIyCLwFODUL thcv+cV6LTzSQvAh0QknpKDmpQU8RRjn7Y7XQf9jeaCe/Sy21825rxbuFcGWb/odrWPb 2wcvIDSp1jXLo+oSBr4B1VHqyBHH+3ZUERZHrehoMn5/IPWL1zGejdEpUtWW4voIWFIQ cPGg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=TVv29Gu9R0lZt1E9Lqgvg+RLu73iRTIWopGteUyS5tk=; b=GoN6tdNEgLGVT8nTvj66RND7VIL8jTq8RDyNwoDfQdYG/MCu7SOPCYcgHI9z1MwPIj W4x+Onj+7tuyN3a2R9ZJRW2inVEKawPUze5BCc27kRCDo99zb2qflVVkN0DNfIcBTdzD dSCQPnivEIYVRMlsIdB3pMfIsLHh74IYjdTxPCCR0K8oK+gGZWLrbTKKdlXqa6sndgNR tC2SF3THLWhzYan7thgOvpZzyUVtlFJcMQX5SIWkMV2xb9DTyoeSSJS+z4Z9JULJSrqy J3wvwh0f1Zx9Z36cpkB6OvsQQb6ZO74U0abfrcer5/351S7baiaeksZjyrFK5BPsJFEc TzYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lCofLKqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bj23-20020a056a02019700b003806fb452d8si9021746pgb.721.2022.03.11.14.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:36:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lCofLKqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 981B032795B; Fri, 11 Mar 2022 13:42:24 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347117AbiCKQZe (ORCPT + 99 others); Fri, 11 Mar 2022 11:25:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349035AbiCKQZc (ORCPT ); Fri, 11 Mar 2022 11:25:32 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17596106C88 for ; Fri, 11 Mar 2022 08:24:28 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id l1so6311388ilv.3 for ; Fri, 11 Mar 2022 08:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TVv29Gu9R0lZt1E9Lqgvg+RLu73iRTIWopGteUyS5tk=; b=lCofLKqu1VnbBCzaNpXV1knnGKNcPMluFAY18Sxq0Ca91tipY9CRbnwsMQkTdvik8F SEOXnZRQxFAEERaWcST0h0s2XHvTs0kDaVF7br7uE7wlaR1SgaBnVMYVy1eVZhICq3d+ J4I3/GXLR4cGzJ35vLVuTEhDhSy06DjuoxSI3qjS0Kn0JoWRDAEznTb/KQUodcliR77J 6OqmsVAp8PJnJcvlKegxhcKKpPqO+KBXHYWpqgCmzQ8EKsO6M/sigADy85m0mea6f0b6 FM2iay5XDea5wMhPdMdntbPIeDwXmzAj3zIBFASvL/N2MEKawd4LO6UfhpQX8Akv5Gyx uxBA== 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:mime-version :content-transfer-encoding; bh=TVv29Gu9R0lZt1E9Lqgvg+RLu73iRTIWopGteUyS5tk=; b=rGmHCyLOe7DuxUUQXhbPdL+uZbDHF8QHS9gM3BZv01klxe6dFo3PoyzoIhYt2XRBLK Zb8QU5Yjy4H7SSgNXgpmdrSAGHBWtLlH0irEpNEDmnMQsf/dRkkbbM1uf8BN28LsUO8K w69nTlOUXsivPFvawDnaUopwlwaUxReAAca3a8setykfHree7Drb0EN16mb+HW1kme+E ILAlewThKM2w6NCbp8yc2tP0pcYR8SFbhMz/lQtzdsQl0iXwQx1X3jRK7nWsXMqo9RGT i0vqmSWLV9CdstWPD0N583n9ObtmGZkmlWslrum2fa+FtzxXYQvJutBdJngluLgOR/Ou Q05A== X-Gm-Message-State: AOAM533syBB3ivtNLFmbQFOVHu6+8IclWXj1jSgsibiao8Nuku1kvBkZ LY2bt5NkwIDcrRjbLNYkwnTJbw== X-Received: by 2002:a92:ce91:0:b0:2c6:272c:bb51 with SMTP id r17-20020a92ce91000000b002c6272cbb51mr8214045ilo.170.1647015867291; Fri, 11 Mar 2022 08:24:27 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id 4-20020a056e020ca400b002c6266f4876sm4477042ilg.84.2022.03.11.08.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 08:24:26 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/1] net: ipa: use struct_size() for the interconnect array Date: Fri, 11 Mar 2022 10:24:23 -0600 Message-Id: <20220311162423.872645-1-elder@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 In review for commit 8ee7ec4890e2b ("net: ipa: embed interconnect array in the power structure"), Jakub Kicinski suggested that a follow-up patch use struct_size() when computing the size of the IPA power structure, which ends with a flexible array member. Do that. Suggested-by: Jakub Kicinski Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 16ece27d14d7e..db5ac7552286e 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -374,8 +374,8 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data) goto err_clk_put; } - size = data->interconnect_count * sizeof(power->interconnect[0]); - power = kzalloc(sizeof(*power) + size, GFP_KERNEL); + size = struct_size(power, interconnect, data->interconnect_count); + power = kzalloc(size, GFP_KERNEL); if (!power) { ret = -ENOMEM; goto err_clk_put; -- 2.32.0