From mboxrd@z Thu Jan 1 00:00:00 1970 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 9DFBDC27C65 for ; Tue, 11 Jun 2024 21:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zs7KBzPQ1AQslUo5E1/7Nt9NISBd0hSZyU+UCo3100U=; b=nnVC1SUkgtdVveCuBkupIPpUx8 nrnWRUqSw8sFE4UrZ0LpdvTcw8MmVY/vTY1uEDhnundEd04hPg7Vt4UG9Oe42byJ931EaGskwZDBj JhIWRad8fSYCQqul0yNrNLrO6EfYvrh2OogLUGFZzhsvh3UVVm0x5Fc1lltW1XXooxJ/4lTZnjwOX l6/blFie36IqKrpbb5/QdmF/ZuboBqRcstdvRrLM0kTZecfRTL2qvnHLfOb0umEGBoqE6nFWdawdS IJRGtyT+3OCVVarODnX5jFK6nv/b5k1b6DRs7LhcBVmoWHceuGrgqqXITvsGPQbYbzg41w8F/p0/6 uB0EA+QQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH8xZ-0000000AGfm-0vND; Tue, 11 Jun 2024 21:23:17 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH8xW-0000000AGfM-36Gc for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 21:23:16 +0000 Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5657A512; Tue, 11 Jun 2024 23:23:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718140980; bh=e83GC/a2Xg/kbv5xMigo8i1S1a4boPruaYPqagwhBNI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=de4IqufyUOtpKTx177g5clRXPPZDNt5MXWcV4TSZvReAM38dGg/htSJVtlK7/Afxv EXKqsQVcxsups0qxCEc3kbxRjG79daXSNDa5AwwtvECdYcDDKg8+9hQuHLv5DIf8w2 Vo2BmUzjJQUiVzoDpGqz7WYzdzsaUuFe2my9JNb4= Date: Wed, 12 Jun 2024 00:22:53 +0300 From: Laurent Pinchart To: Stefan Wahren Cc: Greg Kroah-Hartman , Florian Fainelli , Umang Jain , linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 05/11] staging: vchiq_arm: Get the rid off struct vchiq_2835_state Message-ID: <20240611212253.GF10397@pendragon.ideasonboard.com> References: <20240604172904.61613-1-wahrenst@gmx.net> <20240604172904.61613-6-wahrenst@gmx.net> <20240605071109.GG879@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_142314_950760_7252FFA4 X-CRM114-Status: GOOD ( 23.10 ) 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 Hi Stefan, On Wed, Jun 05, 2024 at 12:11:41PM +0200, Stefan Wahren wrote: > Am 05.06.24 um 09:11 schrieb Laurent Pinchart: > > On Tue, Jun 04, 2024 at 07:28:58PM +0200, Stefan Wahren wrote: > >> 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. > > > > Do you have plans to address the design ? > > by using kzalloc and assigning platform_state at the end of > vchiq_platform_init_state, i would consider this as fulfilled. Or do you > care about the possible platform_state NULL pointer? Reading the commit message, I thought you meant further changes were need to fix the design. A clarification in the commit message could be useful. > >> 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(-) > >> > >> 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 -- Regards, Laurent Pinchart