From patchwork Thu Sep 14 03:31:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1835892 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rpw1F6S7nz1ync for ; Mon, 18 Sep 2023 16:31:29 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Rpw1F5hMbz3ccM for ; Mon, 18 Sep 2023 16:31:29 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.188; helo=szxga02-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) X-Greylist: delayed 3300 seconds by postgrey-1.37 at boromir; Thu, 14 Sep 2023 15:21:47 AEST Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RmQfg6xQXz3bZv; Thu, 14 Sep 2023 15:21:43 +1000 (AEST) Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RmN9B73nlzVkVq; Thu, 14 Sep 2023 11:29:34 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 14 Sep 2023 11:32:23 +0800 From: Jinjie Ruan To: , , , , Eddie James , Mauro Carvalho Chehab , Joel Stanley , Andrew Jeffery , Hans Verkuil , Jammy Huang Subject: [PATCH] media: aspeed: Fix the NULL vs IS_ERR() bug for debugfs_create_file() Date: Thu, 14 Sep 2023 11:31:35 +0800 Message-ID: <20230914033135.3760727-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-Mailman-Approved-At: Mon, 18 Sep 2023 16:30:49 +1000 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ruanjinjie@huawei.com Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" Since debugfs_create_file() returns ERR_PTR and never NULL, use IS_ERR() to check the return value. And so return the err code based on IS_ERR instead of checking NULL. Fixes: 52fed10ad756 ("media: aspeed: add debugfs") Signed-off-by: Jinjie Ruan --- drivers/media/platform/aspeed/aspeed-video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c index a9c2c69b2ed9..f4e624c13d3b 100644 --- a/drivers/media/platform/aspeed/aspeed-video.c +++ b/drivers/media/platform/aspeed/aspeed-video.c @@ -1975,10 +1975,12 @@ static int aspeed_video_debugfs_create(struct aspeed_video *video) debugfs_entry = debugfs_create_file(DEVICE_NAME, 0444, NULL, video, &aspeed_video_debugfs_fops); - if (!debugfs_entry) + if (IS_ERR(debugfs_entry)) { aspeed_video_debugfs_remove(video); + return -EIO; + } - return !debugfs_entry ? -EIO : 0; + return 0; } #else static void aspeed_video_debugfs_remove(struct aspeed_video *video) { }