From patchwork Tue Nov 7 09:51:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13448231 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 49BD6C4332F for ; Tue, 7 Nov 2023 09:52:43 +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=arj09Oa1e5CwKJ2WsJkQjKeQc2s3T5EebF5wsPE4GfE=; b=NsCm7HDcaMTgCA 5nSbnwmilPrKmJ4wC8qnjEl0TVR/eCfhiMK8+w98VSQaYpj+ZRGERH/mx9RWdHOXqDgXgUW56ZPp8 uodFqEqdHfTIy8hUInvd6arPSCKTnhB8JNBdCTguJP0G7hZNyA26tpd+t0QRU+LWUPTHc4m+13/PP 74hUYzY9+AxvNiAWBxFdycibAIf5TNP++m3fMAffWBd6CMnSdw8Pb/ajUUJMs4z3rxWObXWQZX22W DII7K0QhMJ9Cbxe+gMMdpK+SrgC0pomYenBZQcBpFiqS2GkC6bmrP+FhiuQe+2QwKsZPVTWjJAUy4 20nr+/69CJv6JjAcEqbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0Iks-000xM6-2o; Tue, 07 Nov 2023 09:52:18 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0Ikp-000xKf-32; Tue, 07 Nov 2023 09:52:17 +0000 Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57302D8B; Tue, 7 Nov 2023 10:51:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350713; bh=OSaU2JfcRpqaoQ4rtzBWYlTRgjft76ZQtKn1Q/INCPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NlmWAtbNmBLdIaH/LGalMA5siqISenWvl3SJ79wlWPstu27dRxQg2KIiuYxScM7DQ z6KbXIViNZ6sTTJExMe91MyCUBeFddOBkHVF0opTtR1mXzTOeuQWGd4duDhBdhtSUX ibD1nnxqWsh7tZlfDgzOX856y63X2A0eeKNN5wus= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain , "Ricardo B . Marliere" Subject: [PATCH 2/9] staging: vc04_services: Log using pr_err() when vchiq_state is unset Date: Tue, 7 Nov 2023 04:51:49 -0500 Message-ID: <20231107095156.365492-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-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-20231107_015216_158373_98E1D837 X-CRM114-Status: GOOD ( 11.49 ) 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 Reviewed-by: Ricardo B. Marliere --- .../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;