From patchwork Thu Nov 2 21:06:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13444204 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 E6A4CC4332F for ; Thu, 2 Nov 2023 21:07:08 +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=EKTHfunKv5EXilKXvgf+X+6mrLXmktdpXK/KoM4rFDI=; b=RMo9fiVESnArdq claTot1WE4Kb5heGjc678yYTn5sgQxbjhK9OyQarrA/JZg5ud9bQqTUtu4f3IwO2ZaMDp/GBKCIcE toYBWoYvUVb98bI4wfQgiL0q5aK/tg1ZvmcjL6wMtrrHcZH2s5RZjCY8YQe+fvclDlUqu5BJVDC2J iPK+hY0MT1iWDK87H6o4KFXMJ2z1cL/BqrrDDFzSP/8j+7l8IVp+eSGODFXaZMdkRouoQ4QFZx+To k1St3k8flzyMRs9iWWPM2n7zru+qEpFsn7xs2aBfgXElpHcYTCJX2NrN6lUnhl3xb0hDw1hxHyM/w LpUqkSqTBqXD6XDY69HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyetX-00AI06-2r; Thu, 02 Nov 2023 21:06:27 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyetP-00AHw2-2K; Thu, 02 Nov 2023 21:06:25 +0000 Received: from umang.jain (unknown [103.86.18.252]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E335C58; Thu, 2 Nov 2023 22:05:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698959160; bh=g9HzfZmE3ZTc4WYjPHq8NUaGArWYbSyR+SDvRDMfWbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f34InSJ4zuWTnqz8o3vseg3vLJLp6bKr8J12nENr+rN6xNpRYdO5J34VhW+qvFn3X JwCwYbCDrBKvJe5sbs7Wv196g87asy6/U4Hy5x/OyuIhGg9vjU4oKPQDHeU+TRjQry z7oFkUj8S8TErHvJmzNHxFFsuTf2UDU2pSoFv2t0= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Kieran Bingham , Dan Carpenter , Phil Elwell , Dave Stevenson , "Ricardo B . Marliere" , Umang Jain Subject: [PATCH 2/3] staging: vc04_services: Log using pr_err() when vchiq_state is unset Date: Thu, 2 Nov 2023 17:06:02 -0400 Message-ID: <20231102210603.1201311-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231102210603.1201311-1-umang.jain@ideasonboard.com> References: <20231102210603.1201311-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231102_140619_896434_4671993B X-CRM114-Status: GOOD ( 12.47 ) 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 In cases, where the global vchiq state is still unset, we cannot log to dynamic debug (access to struct device is needed, hence potential NULL de-reference). Log using pr_err() instead. In vchiq_initialise(), remove the 'goto' because it is just again trying to log to dynamic debug. Simply return with -ENNOTCONN after logging to pr_err(). In vchiq_open(), move the vchiq_log_debug() after the state pointer null check. Signed-off-by: Umang Jain --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 ++---- .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c | 7 +++---- 2 files changed, 5 insertions(+), 8 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 9fb8f657cc78..9fb3e240d9de 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -687,10 +687,8 @@ int vchiq_initialise(struct vchiq_instance **instance_out) usleep_range(500, 600); } if (i == VCHIQ_INIT_RETRIES) { - vchiq_log_error(state->dev, VCHIQ_CORE, "%s: videocore not initialized\n", - __func__); - ret = -ENOTCONN; - goto failed; + pr_err("%s: videocore not initialized\n", __func__); + return -ENOTCONN; } else if (i > 0) { vchiq_log_warning(state->dev, VCHIQ_CORE, "%s: videocore initialized after %d retries\n", __func__, i); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index 0bc93f48c14c..3425d2b199c2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -1170,14 +1170,13 @@ static int vchiq_open(struct inode *inode, struct file *file) struct vchiq_state *state = vchiq_get_state(); struct vchiq_instance *instance; - vchiq_log_debug(state->dev, VCHIQ_ARM, "vchiq_open"); - if (!state) { - vchiq_log_error(state->dev, VCHIQ_ARM, - "vchiq has no connection to VideoCore"); + pr_err("%s: vchiq has no connection to VideoCore\n", __func__); return -ENOTCONN; } + vchiq_log_debug(state->dev, VCHIQ_ARM, "vchiq_open"); + instance = kzalloc(sizeof(*instance), GFP_KERNEL); if (!instance) return -ENOMEM;