Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1358608rwd; Tue, 16 May 2023 16:15:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6IEwnOfykFgqCrYMcR5J0GY0IvXC2MFVb8lSLBkClVqs4uHtEuZ3+o7sgC9+/eOfSv59SE X-Received: by 2002:a05:6a00:885:b0:63d:3595:26db with SMTP id q5-20020a056a00088500b0063d359526dbmr52591010pfj.23.1684278942319; Tue, 16 May 2023 16:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684278942; cv=none; d=google.com; s=arc-20160816; b=gicNshMoGWmnDOdOUvoe+0UiMP8ft8Zv+RRO5dwSe/U2RV8re95LlrJp7eNqQyBdYe Mq5iQ1JyeVWuTkt4ztZD4fDEkczAuM9X18SaIrlt2LvpftGddQjwr+USo7S4EEO7SfEn HcYouetf/+YN7MQAn9TvuUkq87HHp0gVknmfBao/Afprr7JnCvelWegzX/xIkgdwQixW Ssyl6laC0c3ZpZspK72mwihX3ANLUxXJi99HBpiS6/T5ET7m7wtY2xD6lzPN5XOIBlIi XzzE2YnR/z6nBSFs7bRGAiSqV2gCfmqF5xBDwSAth62qQKxEWrrUtvCqv4mDPPBv+0kv wEvQ== 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=vBbnpYGCxI40QdqhlGYWlUbGFCeu1Y+QGty7t4B7s4o=; b=GBlCE9It2xtd9exsg0xYKqLgHd/GaER3OXJyhLoC+aVeVesJlD6n4Bq+FOxPsHLpOE BwDgqI4U6jWNMI1/eovkZc7SqCwdzTqmLEsmrWwJsXr59BU9SSAsaY3PhpALJh1NtoK7 xBmNm3g4MFKzkRLAI+Px7wWBte1QPL0URWLXatslOWubg1kLXnlQ2WlTksDQ9yvN7cXs mvXX8CjAMstYreQY/pONEdFhTJxztIuUMqsG+4ahwibZWO3crY8leNAot4JVBJXGl7rP VPX+1NARNT3SHWZ6OPLZo1AozuFXwbQOEs3zdbmrnSUlg8pF6HNRc9QmaVBx7Y8rul/C kGAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t5U7Yyk6; 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 y143-20020a626495000000b00644c38feecfsi20513377pfb.68.2023.05.16.16.15.28; Tue, 16 May 2023 16:15:42 -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=t5U7Yyk6; 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 S231309AbjEPXNz (ORCPT + 99 others); Tue, 16 May 2023 19:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbjEPXNw (ORCPT ); Tue, 16 May 2023 19:13:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB1776AC; Tue, 16 May 2023 16:13:40 -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 E22976353D; Tue, 16 May 2023 23:13:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FEBDC433EF; Tue, 16 May 2023 23:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684278819; bh=ojFglRzZiKwXiqGnsWelyrmIMH1NnaD8AsZ7Wnf3niE=; h=Date:From:To:Subject:References:In-Reply-To:From; b=t5U7Yyk6479dQQEpLnOeyQ6rFAMBTkM4YJjSvLR0anyUjoJQm24IHqLG3DM+kJ5LM XbPKttG8ckt06eFvVEfm1cSTN98GHa15hI373WCRI3kImxceyyJEj82gr2cPUqjx7V wsh+Mc4CXX8KVxXM9BAFBTQfJ3x3ZhSrQ8SMUYOOysnZlQ5C/T4ru4Xk1zFGB80l5f srkPfZJNx9vfrUZpPeWOiw4MdavVd56SPxXG3z0PFcpQt0whDGXIMb9g1OuEeVaId5 ooR4LE1b/ldaSbNtI1KSuuayFXN33aziOOzLnO/p1qvxQgjeUv2tDJltn8z5F4YR06 d4NaIcfPoYIYQ== Date: Tue, 16 May 2023 17:14:27 -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 1/2][next] media: venus: hfi_cmds: Replace one-element array with flexible-array member 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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element arrays with flexible-array members in struct hfi_session_set_buffers_pkt, and refactor the rest of the code, accordingly. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1]. This results in no differences in binary output. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/292 Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1] Signed-off-by: Gustavo A. R. Silva --- drivers/media/platform/qcom/venus/hfi_cmds.c | 12 ++++++------ drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index bc3f8ff05840..21d1b3c90dc0 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -200,8 +200,8 @@ int pkt_session_set_buffers(struct hfi_session_set_buffers_pkt *pkt, struct hfi_buffer_info *bi; pkt->extradata_size = bd->extradata_size; - pkt->shdr.hdr.size = sizeof(*pkt) - sizeof(u32) + - (bd->num_buffers * sizeof(*bi)); + pkt->shdr.hdr.size = sizeof(*pkt) + + bd->num_buffers * sizeof(*bi); bi = (struct hfi_buffer_info *)pkt->buffer_info; for (i = 0; i < pkt->num_buffers; i++) { bi->buffer_addr = bd->device_addr; @@ -210,7 +210,7 @@ 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 - 1) * sizeof(u32)); + bd->num_buffers * sizeof(u32); for (i = 0; i < pkt->num_buffers; i++) pkt->buffer_info[i] = bd->device_addr; } @@ -243,8 +243,8 @@ int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt, bi->extradata_addr = bd->extradata_addr; } pkt->shdr.hdr.size = - sizeof(struct hfi_session_set_buffers_pkt) - - sizeof(u32) + (bd->num_buffers * sizeof(*bi)); + sizeof(struct hfi_session_set_buffers_pkt) + + bd->num_buffers * sizeof(*bi); } else { for (i = 0; i < pkt->num_buffers; i++) pkt->buffer_info[i] = bd->device_addr; @@ -252,7 +252,7 @@ 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 - 1) * sizeof(u32)); + bd->num_buffers * sizeof(u32); } pkt->response_req = bd->response_required; diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.h b/drivers/media/platform/qcom/venus/hfi_cmds.h index 99bc0b6db67c..ba74d03eb9cd 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.h +++ b/drivers/media/platform/qcom/venus/hfi_cmds.h @@ -117,7 +117,7 @@ struct hfi_session_set_buffers_pkt { u32 extradata_size; u32 min_buffer_size; u32 num_buffers; - u32 buffer_info[1]; + u32 buffer_info[]; }; struct hfi_session_get_sequence_header_pkt { -- 2.34.1