Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1365714rwd; Tue, 16 May 2023 16:24:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZuldTLlmBIwjeJIzkOWq6DUnKapJlv3/BR3Ps8fEUTLMadmsLlxBof1RqgaXe0HTFwhWt X-Received: by 2002:a05:6a00:2303:b0:64c:ae1c:337f with SMTP id h3-20020a056a00230300b0064cae1c337fmr9140050pfh.12.1684279468843; Tue, 16 May 2023 16:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684279468; cv=none; d=google.com; s=arc-20160816; b=tuq1JK/AK+CsNEjbwX+LwEQd1amtefd90p6JP1X8CWZgyakmQCiLuB56NdtAfPkrQg vGbAW8usuG7GARNhRSJmrTdOh0njVwgQ7SfjFYY9OVfXR4lz9Cbehvg+7xiOoPN7fzLB /4nRZyvENYe/fchyIY7NaUuSnjC3ANHupPxoB2OLHgezIS6Nl6j28A1mbmRTJ9bT5qm/ xJOXSTjR3N/4ouBqACqz7ue/4fDujbqcJ/bMcOkfdUozmPIi3C7LwG8zaYCCawfDlGxp MxQaoZ4W2bPDSoHfblTzXt0DhX0hf+RA+SODwMCOGHFid6yskA08SABgTOFoyKsBtmNW HOmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=qxrC1+9u9geKISW5J5QNbdME7VM3IPNIjuoTXcPrjzg=; b=KBaaMeuSEDqDMptDwuSCd8y56/GB64SXmRIOie7vRae2V0A2RUjWbiDSyjEPXNimIV IchtUO9eQD+dQnI5IiG/oFwraGjYHX1tUX+jxlU/iyWXaxUb98uu+rtaOOl61fE+q9Y0 RDfaP51Vp6YQDH9N1Jpgf3uZsfLjo9w8ktqVyNaN33s2Z1n7wPpmhw8Xlh0p/FPKQtfK oZdgVL8FYy2ags71UN71dTn59fnW+PbZ8EimtfuSqkn88wsxDqraGo3pvqKy4uGJqtqx nLmzGj/wmmj0v7XStvF23BrgfPYESrN5VOvaEICSt7lnLkfBEj0OheYDUxflWQOkUHAG LKDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="We6kEj/i"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b132-20020a63348a000000b00502d73d59f4si19903206pga.222.2023.05.16.16.24.14; Tue, 16 May 2023 16:24:28 -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=@kernel.org header.s=k20201202 header.b="We6kEj/i"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231401AbjEPXON (ORCPT + 99 others); Tue, 16 May 2023 19:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbjEPXOJ (ORCPT ); Tue, 16 May 2023 19:14:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D0776B7; Tue, 16 May 2023 16:14:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 779596353D; Tue, 16 May 2023 23:14:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E049C433D2; Tue, 16 May 2023 23:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684278840; bh=qaUrBJYyxwwKBd2OY03a0I58URs2kzWjK7mA8MAbaNs=; h=Date:From:To:Subject:References:In-Reply-To:From; b=We6kEj/iS+wYQuFQ6YbadjiFGSz9PNkVtATeks2aNWZ4b/s0nHpOeYGVdeB+QoMv/ ZEgm8y7BP/0iYJeGUlWyGq9RkwgpL2eyi/1Pzd6+Q5g+AQIZRV77yQCv+kibn+wEFo YOYe6qZacSRxylsteDg3/DS5GFbuoUFdVjl9x9ptW44T1yxoSuJaKXnViTFzJq4sTP vcC5B/qvpuUMLdEPw4rgt8YyRuzN2I2hxgbwseyaoU1XpgMYO5FJaqsWF0BzDiljXp kK77kxVG0irXdy1iDpoKix2jzzE8awrzLmQM2o9nvVVZXL5htSBVBr2RKhwcqnOk4Q G4zGPIQHjJdnw== Date: Tue, 16 May 2023 17:14:49 -0600 From: "Gustavo A. R. Silva" To: Stanimir Varbanov , Vikash Garodia , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH 2/2][next] media: venus: hfi_cmds: Use struct_size() helper Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Prefer struct_size() over open-coded versions of idiom: sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count where count is the max number of items the flexible array is supposed to contain. Link: https://github.com/KSPP/linux/issues/160 Signed-off-by: Gustavo A. R. Silva --- drivers/media/platform/qcom/venus/hfi_cmds.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index 21d1b3c90dc0..3f74d518ad08 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -209,8 +209,8 @@ int pkt_session_set_buffers(struct hfi_session_set_buffers_pkt *pkt, } } else { pkt->extradata_size = 0; - pkt->shdr.hdr.size = sizeof(*pkt) + - bd->num_buffers * sizeof(u32); + pkt->shdr.hdr.size = struct_size(pkt, buffer_info, + bd->num_buffers); for (i = 0; i < pkt->num_buffers; i++) pkt->buffer_info[i] = bd->device_addr; } @@ -251,8 +251,8 @@ int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt, pkt->extradata_size = 0; pkt->shdr.hdr.size = - sizeof(struct hfi_session_set_buffers_pkt) + - bd->num_buffers * sizeof(u32); + struct_size((struct hfi_session_set_buffers_pkt *)0, + buffer_info, bd->num_buffers); } pkt->response_req = bd->response_required; -- 2.34.1