From patchwork Tue Jun 4 17:28:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13685713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FFECC27C53 for ; Tue, 4 Jun 2024 17:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kfu2mC7H0W4cEUCl7Vsba9NfOP4nrijJBub4TMVDCwM=; b=rL9lX1P7YxlUyj /xghRaRrjhvZzFrA80DEFxjH6pUvq1HYKHPBtMLYomjRHQor/XNpVcEzQpiuMOsSy1IwNqSY7g+Gq CLVBE/a2Jz2Z6nU/k3nGM3W6n/+9MWxTWgaahZXBxUh7ZPSmURIKJSOaRfGAqbCxK1PKpauvrilNG uBnqwkfLGJpwhqT9b33aIJTSb0NjEZRs6l6YHgDBgjzsn9ZymN1egLEQAZ+qLeUz0lj6G8Eb0zvYj VIDxROJdyr3NRxVzMEZ/M4O/zlh773+eX5S/rBgW9C50pxTRHdtznkeMVqV6g8eTb5gv9hkkI4HjM K5w/1V2T7Ww3ClUxfR4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEXyj-00000003IpR-0zyj; Tue, 04 Jun 2024 17:29:45 +0000 Received: from mout.gmx.net ([212.227.17.20]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEXyS-00000003IeJ-1UYL for linux-arm-kernel@lists.infradead.org; Tue, 04 Jun 2024 17:29:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1717522164; x=1718126964; i=wahrenst@gmx.net; bh=cPi4YOg3++c1NzBOCaXmqdHTfRwQCOT+4zrHxzV2j+c=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=bmfXTvai81PvpmoP8rkg4jrwBW2Kl6rgJmzSJBwTsXvBTdxTmH9411uxjNFcUlIg 9sBVKUUeL+Qc/Ya/e1DYtCK1BQJvZV/kmJWo3WZM0Cj6gOeD4FsKNYpS+oVl/e1QQ h2EGaZWg+/vJUyCFTp0jazJD8Ya6tEgTlDVSo6xMeyf6Fa4aIebgHAvpvqW4jBJY3 fsVBW7ATnA/HwrttOKgEFusqoMBHYP3xL8cBtGTiEC2csD2kWPRNRvyaWqIEmZJZ0 vu98oWuUvUAXZBfsurT6UvGczoziZs2O/ruEXtJjEkB65zLRRQ7bDmmAf3F8KnXTE sHybU2irHDlwu5Ft8Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MXp5Q-1ry1960ieS-00VA3t; Tue, 04 Jun 2024 19:29:24 +0200 From: Stefan Wahren To: Greg Kroah-Hartman , Florian Fainelli Cc: Umang Jain , Laurent Pinchart , linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH 05/11] staging: vchiq_arm: Get the rid off struct vchiq_2835_state Date: Tue, 4 Jun 2024 19:28:58 +0200 Message-Id: <20240604172904.61613-6-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604172904.61613-1-wahrenst@gmx.net> References: <20240604172904.61613-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:Y201S/auoNhGuy1Zdhgan48f7+dU9nXqYq/STRvIFilo6dSWN0b IZXbfFXTWwIRurufUh75bEmSJhTXu3/jB+3jNFUstQm743WLqqInIDCwbN2XEK49uVgH6Ik /WVIICPuUI42pbrWlJTikJSxzfaf/pskGHXLM5PwfhUtmKtj72VrWXi+vweGzwi8IFYMHvn jMo1j8JGqEwt2FKygzHQg== UI-OutboundReport: notjunk:1;M01:P0:cp8TfH8WKaE=;3o+TwRnRIoUkhMqvaVvV2peoyY5 0++BRiKOPyWyChPDpJJoKMo5WYKOWbhmm83tjnFzriuFDSmxl71HJB7F9LWM7tNwu5oQYB4/t Qn4+pnLK0roZIfaUBNM3FXo13YfF/4fvRb5KyIqPXzFAHe4cAX+yBlRSi7n8/wG5e5J6cCsLz sa0EPuf6OF/Vsv4GdEgpEj6no1IbUfZPitOwURIznoRVxjzoyWoxegMKSDob+abxMkaADLugi BPtWHpseXvtmQyRt1tIZCN37b1Ukrleeb1vLNDyKUkWskezBTgLLgyEJKyOFWPMH7bATS11YD +dFKFdjFxoz90+WN/Mq61lGw12lCqak2uYMa4LfFcIHm7ocDiGR8Q3HXaDSId4SZwZgb7k08D c4U/s0L+JoobmUtABnYpET+LKZotskhnfucPUzahT/OM8HoTwQBcCcOd/2R2yybOMPdjW6kv7 URu+k3/45z86NOrwqdx2xBdZ3WWnv+zXG6QIdIdoGwGj4v6RceQBGjGUh8DfYXm1GDPeACe3o o5pwbx85ImX3BJLPnaHsU5c+xV22xZiM20Ff49I+usufIiujDPG2VAYI6zu6TSJc7AlAePz1Q pVSYOinYa0VcpNyZu6Zotqbo5C4SSnNHxcoa2faoTRU4BxRs4ZVUQdqpIuqKJErLPmJ5dPBOr waKD2D0ha3Efvoz1s2t7DJuL66yKd1y4lofPT7UjhhGBq1xWhNX1PF1aWNSCc6QYpgqtCETu3 ap2AArZ22uCsQo2T6L8c6Ug7OA43TRdCH1e2Xi/8xBK7v9B/ky8rGXMBALEOqdy03jWeYnEny ODQSvtYrIp/HJjaveCMXLIFsV+wOuBy0tRoSLEbeLux+0= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240604_102928_774255_68AE064A X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The whole benefit of this encapsulating struct is questionable. It just stores a flag to signalize the init state of vchiq_arm_state. Beside the fact this flag is set too soon, the access to uninitialized members should be avoided per design. So initialize vchiq_arm_state properly before assign it directly to vchiq_state. Signed-off-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_arm.c | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) -- 2.34.1 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 515cdcba043d..98a0b2d52af5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -109,11 +109,6 @@ struct vchiq_arm_state { int first_connect; }; -struct vchiq_2835_state { - int inited; - struct vchiq_arm_state arm_state; -}; - struct vchiq_pagelist_info { struct pagelist *pagelist; size_t pagelist_buffer_size; @@ -613,29 +608,21 @@ vchiq_arm_init_state(struct vchiq_state *state, int vchiq_platform_init_state(struct vchiq_state *state) { - struct vchiq_2835_state *platform_state; + struct vchiq_arm_state *platform_state; - state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); - if (!state->platform_state) + platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); + if (!platform_state) return -ENOMEM; - platform_state = (struct vchiq_2835_state *)state->platform_state; - - platform_state->inited = 1; - vchiq_arm_init_state(state, &platform_state->arm_state); + vchiq_arm_init_state(state, platform_state); + state->platform_state = (struct opaque_platform_state *)platform_state; return 0; } static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state) { - struct vchiq_2835_state *platform_state; - - platform_state = (struct vchiq_2835_state *)state->platform_state; - - WARN_ON_ONCE(!platform_state->inited); - - return &platform_state->arm_state; + return (struct vchiq_arm_state *)state->platform_state; } void