From patchwork Thu Dec 21 09:17:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Shao X-Patchwork-Id: 13501493 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 B43C4C35274 for ; Thu, 21 Dec 2023 09:24:03 +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=yLIPGjLE5bdscdDKryuDB+hPay+s5TAU1M/adTj7nqI=; b=rd2OKiLmbeBeCf HxU6Vxo42ULr3N9UcPC2tU5Qhim2WIsECLZ04tcK7Ixm5CTDFam78e3uik/QTGkeq8iWdt7i4JEXV GcYwRKMisKXQcjsZUcolEemjJaJmgMBt4T0jsEDAP0zuXS6A2PLGmTJzkEDCW16G2aPoU+jaF3ghf sHtIcPWPjrLlTbYxVDDW23u1sDMyF5TpVivDsDV9vfMkIg95n8if5H0rcFLPFxVrFN1kla1UZVSag NAeQxf+tDbprzmTLdemIxNlYXNQi6+Z6Z6PjmE4277gdCqrX//isV7St7f8g6d28y8gCJarCq1q4J 4L3uUO2GvOqSqFGtNaTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGFHH-002FR7-0z; Thu, 21 Dec 2023 09:23:39 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGFH5-002FJM-0f for linux-arm-kernel@lists.infradead.org; Thu, 21 Dec 2023 09:23:28 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d84b68a866so326833b3a.0 for ; Thu, 21 Dec 2023 01:23:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703150606; x=1703755406; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YpgYqGOhJKgjrH+Y+gow5aHhwckMqDVFEItsLP1DgtE=; b=mJ9L7koHJdSZzkKN3GpZC8dX+hxlr0daIQmEeLAx+0Q+60upXtPbUpr61zZNoquF+c lyBlAzlGOoQcZYAw32enNkoJxvQ9AD8IoY9tQ66axQPRgrAtXtX3E/oOdDak3csamvmO 08nLWKSKInpFgi1Tvn3jn6G9tBlLvC/Az4Nbk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703150606; x=1703755406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YpgYqGOhJKgjrH+Y+gow5aHhwckMqDVFEItsLP1DgtE=; b=YuP7nV/miLhZ47uhvqkpG7yISmrA6zezAt+4iX28OXA8JL3Ax1JM9v35xcp+eeHWRz M7Zc8PJQBMy7MqX5NajRYq4QCSpsu5dRCyKcAC9ufLZ1a5aTLBzd6penPUVqEG2jX9cO x+tt3hr+VTzjfnniGVNzO7OmKdXh+ygwLqqSVJ7J/krJkfgiYvrRLhNylK7RC05NYsZf bp2RqTIu4u7RL+Djvwe3lQoG+5pejEH3OkbA2eajuNtN9JgSsZX+UDQiTLrTHVe9TAAt r7vHkNvVA5lLHzNBj4UXdI+Y3hoXJVEil2bjAcqKbP7Ut5sDalGqtLLDpUF6JijoqVnH 6Qlw== X-Gm-Message-State: AOJu0YzYTauoX3tEgfbe/1FuQ0QNrhTRq+6gfxYhiNqwTgkwSl6xTjoj cJe85IO6bI7jBlbPUjchyd7jDA== X-Google-Smtp-Source: AGHT+IFnrts3BeDUhUkXV+RyB4brmj4RfCUKgv5oiPG6/u9kJt/qtACQnRiXrrJZ8XuzpZM2y2ZDHg== X-Received: by 2002:a05:6a20:2e25:b0:188:1df7:9afe with SMTP id be37-20020a056a202e2500b001881df79afemr560527pzb.30.1703150606111; Thu, 21 Dec 2023 01:23:26 -0800 (PST) Received: from fshao-p620.tpe.corp.google.com ([2401:fa00:1:10:5d8a:fab1:933a:9ae9]) by smtp.gmail.com with ESMTPSA id l6-20020a17090add8600b00274b035246esm1001915pjv.1.2023.12.21.01.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:23:25 -0800 (PST) From: Fei Shao To: Hans Verkuil , AngeloGioacchino Del Regno Cc: Fei Shao , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Nicolas Dufresne , Tiffany Lin , Yunfei Dong , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 3/4] media: mediatek: vcodec: Update mtk_vcodec_mem_free() error messages Date: Thu, 21 Dec 2023 17:17:45 +0800 Message-ID: <20231221092226.1395427-3-fshao@chromium.org> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231221092226.1395427-1-fshao@chromium.org> References: <20231221092226.1395427-1-fshao@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231221_012327_244829_97CAD2C7 X-CRM114-Status: GOOD ( 14.99 ) 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 mtk_vcodec_mem_free(), there are two cases where a NULL VA is passed: - mem->size == 0: we are called to free no memory. This may happen when we call mtk_vcodec_mem_free() twice or the memory has never been allocated. - mem->size > 0: we are called to free memory but without VA. This means that we failed to free the memory for real. Both cases are not expected to happen, and we want to have clearer error messages to describe which one we just encountered. Update the error messages to include more information for that purpose. Signed-off-by: Fei Shao Reviewed-by: AngeloGioacchino Del Regno --- Changes in v2: - update the error messages based on the suggestion .../media/platform/mediatek/vcodec/common/mtk_vcodec_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c index 23bea2702c9a..c60e4c193b25 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c @@ -96,8 +96,9 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem) } if (!mem->va) { - mtk_v4l2_err(plat_dev, "%s dma_free size=0x%zx failed!", - __func__, mem->size); + mtk_v4l2_err(plat_dev, "%s: Tried to free a NULL VA", __func__); + if (mem->size) + mtk_v4l2_err(plat_dev, "Failed to free %zu bytes", mem->size); return; }