From patchwork Thu Feb 29 09:56:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 208283 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp285055dyb; Thu, 29 Feb 2024 01:57:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWJB0Ug0nVcqyLnV0wVUyyXYyhcQCqoAkhnAssF1NPEpxZgzV6ZsYXimKd0ZEYnsQ5vVfGjZr6xa7tjlqukWydwuN/93g== X-Google-Smtp-Source: AGHT+IGKpErFNEmh5T0UmDMv3MKaffY2C7HefLuQ0gC/enEmuuR18eyp+kxarKSjb52/GdH1Kfcd X-Received: by 2002:a05:622a:30f:b0:42e:9fb4:d2c9 with SMTP id q15-20020a05622a030f00b0042e9fb4d2c9mr1576134qtw.66.1709200651584; Thu, 29 Feb 2024 01:57:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709200651; cv=pass; d=google.com; s=arc-20160816; b=vyTofR0fh518XwDhdE9qcsh9DIU5yfArsX31ucWby3sDH/aSMi3oC5faLzkOdRiUS2 qBuM0QoaU6vWtQz3+zIuxLb7ixbj73vH/1l8VvJdvWDXg+KHunNPprs0yhRWF1ACn4Gm Pxzet90QIasoZo2auwodyV+M4bPohTjm6uZ4xdlfHp0V9tv081YHg2zA/Al8Q5TZjQcj YVBPUySD99N6EGXOFXh/V/L2sv6CyHcVXTS/bOZ5LJ26vyR0AO9WaD0aOlaf364CY2Tz 8mCr4mFZNBBtwTMkcsxrFE2ut9rN+gW55/qRe1Tgt+ZYUQUOxNdVcwIxwzxdE6wMMuUb jTow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NSJvBf2MtjtGhjMO2/ZFmTYLI8qmp/2QaCoKqPV6uw8=; fh=vx/6R7BPr6HgrHZaed1YdrsZ7o0eyzfJ+468tWgGkhs=; b=dyQ+LGNNwOlay116fMVg3dEcPjQB48QFhyKNAxLl1rqgfaIPV3rNUapfMRc0PNc2ed V1XXy+UrlUlvUaprSaMseAOSax4vrFoptRcLXEB4dLGvKwqenzotgp+XTCXFnSgBcD44 MT0mg5O9PmpJqu3YKWwe9NSaU77GcP2mo73jRQZ3z7CJMi9jIcYo9IEKvyLwuKX0VS5i 4b8HRaK5Fhr/xqxd3OWqq6y+07Y79AsEBZql6O/QirXo4cJjKEU8Ixs1qP+NnJw2Rvlt 8q4u4pGD83zcXE1J4bnAsLCDvdtb5y8RNBBFubYdfio60wSzgnKyC/EUQrZuHMRUugcD oNlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Zo9dDuHu; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-86489-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86489-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i3-20020ac85c03000000b0042e6df3902asi1099500qti.285.2024.02.29.01.57.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 01:57:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86489-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Zo9dDuHu; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-86489-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86489-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5C6691C20EB4 for ; Thu, 29 Feb 2024 09:57:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02760633FC; Thu, 29 Feb 2024 09:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Zo9dDuHu" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1287562801; Thu, 29 Feb 2024 09:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200584; cv=none; b=unImOK2+uDtY4UYcCHvUWEKQFAzM1PK8IxWKMzmcskgLN9NYmgXSN9MxecWjTPghHkFmPDu20MAcMh96zrLewrPPwywxH9AXqO1/4SwjdipVTRNYLjnt50AJ99nxWmiucb+U1o7ppzkRkr3n0FKTerNROtwF7DRGPPoGfYe4HqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200584; c=relaxed/simple; bh=Kuxb7Z7SxDymhUXCf/8OI233Gjndg1g669+lIXC5Gwg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HOL8UFIE8vXcFylE+Ig1ZeYNuJ05CAUBOgXtklSQw5bYPoixBZwlk+rmy6z0fggL6etSfhllQmSJfJu70uV1yYiBUyILt4XhkNl7fP26FktL+pouKlIECDDo4xMp/C2LWPS/JJwL8b3ZH4JSU/ugK4jvaUrVFA0ZN+oAnFKI0xE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=Zo9dDuHu; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: c6d18096d6e811eeb8927bc1f75efef4-20240229 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=NSJvBf2MtjtGhjMO2/ZFmTYLI8qmp/2QaCoKqPV6uw8=; b=Zo9dDuHuECaL8Yegn9VKliddA9lYXyjYw4S+a/rV3ckzUAV4SvfhSYi86uS42expLvTfUcmnAKO09xyx55VY+XEKS0qiorBh1JuNzatBh4Ulij4r3rQjJuMpfThI5ii35LgXhcgTa1MUJFUQSnKy5SAuBY/ZOLfLrGTqpVwhO9o=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:5b0e5b89-0de6-49f0-9717-81229bd439bc,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:6f543d0,CLOUDID:6e18f380-4f93-4875-95e7-8c66ea833d57,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: c6d18096d6e811eeb8927bc1f75efef4-20240229 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1390350831; Thu, 29 Feb 2024 17:56:15 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 29 Feb 2024 17:56:13 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 29 Feb 2024 17:56:13 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH 1/3] media: mediatek: vcodec: fix h264 multi statless decoder smatch warning Date: Thu, 29 Feb 2024 17:56:09 +0800 Message-ID: <20240229095611.6698-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240229095611.6698-1-yunfei.dong@mediatek.com> References: <20240229095611.6698-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MTK: N X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792226782116116997 X-GMAIL-MSGID: 1792226782116116997 Fix smatch static checker warning for vdec_h264_req_multi_if.c. Leading to kernel crash when fb is NULL. Fixes: 397edc703a10 ("media: mediatek: vcodec: add h264 decoder") Signed-off-by: Yunfei Dong --- .../vcodec/decoder/vdec/vdec_h264_req_multi_if.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c index 0e741e0dc8ba..ab8e708e0df1 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_multi_if.c @@ -724,11 +724,16 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs return vpu_dec_reset(vpu); fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); + if (!fb) { + mtk_vdec_err(inst->ctx, "fb buffer is NULL"); + return -EBUSY; + } + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); - y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; - c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + y_fb_dma = (u64)fb->base_y.dma_addr; + c_fb_dma = (u64)fb->base_c.dma_addr; mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx c_dma=%llx", inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma); From patchwork Thu Feb 29 09:56:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 208282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp285033dyb; Thu, 29 Feb 2024 01:57:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTt54JpdZs2QtWQ1+8CkuJ/vCoe7UtalsAY9B45pvGO4xrlHsSlFhecAP/EDd3993qg5/beXIWZ5wKidYzskuROjepkg== X-Google-Smtp-Source: AGHT+IEMmrFNIRcPGu3Ef6jzqwiDIo30G9h9iLlex7AZb9L2Pe8bfU8lkIQPx94jxZKSKoI3Cpjj X-Received: by 2002:a50:ef11:0:b0:566:1952:694c with SMTP id m17-20020a50ef11000000b005661952694cmr1216710eds.20.1709200646423; Thu, 29 Feb 2024 01:57:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709200646; cv=pass; d=google.com; s=arc-20160816; b=odm7M1pj14IFXEg1pf7ZSD+9aUimmQfwKZcz9x2mUfEOaWpBUh3i43jQngDkU4hZaf E6z8iu0h58vfes8fSIAP2m2zIZZWSOqJKw8HhIMcfRPkR5TymlML3TakOywrqvexsfDt ATBdewPvB1z/xnsuOFd2PLr/HYtYfCpD/kZQzSV+il3Vcv4Wjliw2mQRuQLmXoPaZuR4 H1oRgSx5q4j/kPAuIeRoMSHShFn1a85/KkbxjiMPBFnyWuIwocnouV7C4XcZjM4O1+rI mxdnYdExRru+IK0enzDILl/FQjtcH7tWs/0WQBXyWBB+aD2F0wWN1G0nzhKAO/y54kcY Jpyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vbYkOdR4YXvkFb7nENYvJOmgYTU62t95FqAEQhQEksA=; fh=rYZqDNP63tf6+qk2gsh/u90wMd8bq0irMF7JOMts8X8=; b=eQOP7P/zocS39sH+4STAgS5VffjZwa1m+1OpBvqVFtH9HasZo4g9l75aL4hH35cXzO i7CBBC/UHXRChwZ82BDpekJOKoFaD+3Y6jlVe9XBdmpqmsuRG/cDsHRmuS6Y7BjaH8TK EbsoKSIqsGy7p9+Wkc+frCj8Hiei5+a4OHkx7NGtfsLktRoq/kt9MCin8N1o7fQM/Ode 96hDACHo+lEKwM36wsrPnN1AtRnaI1i/kkFMNsCdbUPsxF4Sfwv3vcX2i+GcyGyzYX2+ gpOawXkA+ezFssqljwb5A+NMiu41h1Tcu4Vi4VtmUv1z6cKzjphhiF7TSb0B2nxS6gE6 U+9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=AnH1mJzt; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-86488-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86488-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x60-20020a50bac2000000b00565dff15a8esi441547ede.321.2024.02.29.01.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 01:57:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86488-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=AnH1mJzt; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-86488-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86488-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0969E1F21A56 for ; Thu, 29 Feb 2024 09:57:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15FA1633EE; Thu, 29 Feb 2024 09:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="AnH1mJzt" Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E20B962154; Thu, 29 Feb 2024 09:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200583; cv=none; b=bqAQcy7rjZ7O/BphR4i5KQn8rZgGJGDAdPDchV2ytg1MYQFaJAg4oF17bA4fueMm9IxJSXZgHGp1inWRx6K8nHq/rupOMoBx4hmkRhr8NFUugS08vpCJrOBomStreCVKuElOZZqaiMmWWibYwoPKSEXrj7FLq2972fH3J2geWKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200583; c=relaxed/simple; bh=RdeNyNpr0oqRhCkT8/f/xI23sqLrfIuo7CR+09RayOU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hIrOr+XLlwvynCt6lNAUHbnfRutSYsTmUtiRCsJ6kZiJdXQ4GnB9MiQAipQIDTsMi7PdV0i8WyeTEOR2FRR0zds3+yQDtGNb5Xv6oWBvL2o+IQdX4kARJ9Vn3b0rZmNdDBAT0zCXhSOYd9Lk4tJyJJRM2GyadVqxIt4mZKiMAlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=AnH1mJzt; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: c7798106d6e811ee935d6952f98a51a9-20240229 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=vbYkOdR4YXvkFb7nENYvJOmgYTU62t95FqAEQhQEksA=; b=AnH1mJztX0R2rVy4QCZFpQI7jd0bjY25sNcP60iVESKLe70DNEfWJuDfLDpMQtMpzXjYPB/kiCKzZn2IjWl1cuIFXJenIbn5PUs/BEE8myiYXaFDfjIzprs7iRgW17d2nauPawrj225ELbsVsML9zUUISHO1zxprduHiqB/+a0M=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:48e54849-e68e-4dea-8db3-45d61ccb974e,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:6f543d0,CLOUDID:6818f380-4f93-4875-95e7-8c66ea833d57,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: c7798106d6e811ee935d6952f98a51a9-20240229 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 682567945; Thu, 29 Feb 2024 17:56:16 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 29 Feb 2024 17:56:14 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 29 Feb 2024 17:56:13 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , "Yunfei Dong" , , , , , , Subject: [PATCH 2/3] media: mediatek: vcodec: fix vp8 stateless decoder smatch warning Date: Thu, 29 Feb 2024 17:56:10 +0800 Message-ID: <20240229095611.6698-3-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240229095611.6698-1-yunfei.dong@mediatek.com> References: <20240229095611.6698-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--6.149600-8.000000 X-TMASE-MatchedRID: 1uypKmLkdmeoft0ZW3r/iTCaEJt46PppPtDsRiRP0d9h2fnHe1cil/Rm 0kmqtH+DgHpD5xuuxKghg4hY1jreIwLz+AfRlRoHoprTEHvewACuiRuR9mCaujedlpL1W1muo8W MkQWv6iXBcIE78YqRWo6HM5rqDwqtA7YoH98mDXBUoiigs/hmrA8O+ONIW+vTLTxXPbsT0A6+hl Kq+cOj50MMprcbiest X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--6.149600-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: DE03DC2AA1F2F9BC5D5F995C3FE937AE975382AABD653C06DB85233F7F75B2722000:8 X-MTK: N X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792226777170546051 X-GMAIL-MSGID: 1792226777170546051 Fix smatch static checker warning for vdec_vp8_req_if.c. Leading to kernel crash when fb is NULL. Fixes: 7a7ae26fd458 ("media: mediatek: vcodec: support stateless VP8 decoding") Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c index f677e499fefa..0889517a58e8 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c @@ -334,14 +334,18 @@ static int vdec_vp8_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); - dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); + if (!fb) { + mtk_vdec_err(inst->ctx, "fb buffer is NULL"); + return -EBUSY; + } - y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; + dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); + y_fb_dma = (u64)fb->base_y.dma_addr; if (inst->ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 1) c_fb_dma = y_fb_dma + inst->ctx->picinfo.buf_w * inst->ctx->picinfo.buf_h; else - c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + c_fb_dma = (u64)fb->base_c.dma_addr; inst->vsi->dec.bs_dma = (u64)bs->dma_addr; inst->vsi->dec.bs_sz = bs->size; From patchwork Thu Feb 29 09:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 208281 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp284946dyb; Thu, 29 Feb 2024 01:57:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVSAJETy/uFMD2AVS6cJ8qLpAwCVs6ZX4b9LCc9wrfeZUXQytN0yH0ma6W6NeFcrwIyIKXP/ZXohFTAy2/Xl0Gg+bHfvQ== X-Google-Smtp-Source: AGHT+IG1JHRWUgkljbiMq2SR7uBXmrRCUsF0ci6j3MOj6eHFITEF7zIDfR1KZDXMXrKggq5xsLAW X-Received: by 2002:a17:906:f8d5:b0:a43:dd85:e171 with SMTP id lh21-20020a170906f8d500b00a43dd85e171mr1059648ejb.69.1709200636214; Thu, 29 Feb 2024 01:57:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709200636; cv=pass; d=google.com; s=arc-20160816; b=mvpMXlt8KJROfzlcEMoC76ys6u0AvSrwLnCCJEvHStAQPTADSpGz7sTFo1XN+NmOSW IC16ij00zFJl/hdaUJgNQ8uGYahtGI1ltTeBIQv8hrH57UfhG1Kr/zwidpHxMYpZqz9t 6iCbHBxF5UFZ6j0kC+YuLkixwnBZUN44rFWlt+e7xfQdtStADTk9c15ug/khKZd2Wjme x+ORrZjpDQeNDPm0eUw0FM+i41DPzr3WE+HQ0fC9CNZz4+hzQ+der/Gg+yIS7FnSzxvZ Y21Wd/lyvWlXPs3sLb4nFVYL9V0/WQrwXHpbUqOFg6RMwoVcMP+q7b3Z1P+W3sk/jP95 eh6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=h+/3sZEj2StDKJBFGHkGJp/KMJru0cPHdlEY9qhRQEY=; fh=rYZqDNP63tf6+qk2gsh/u90wMd8bq0irMF7JOMts8X8=; b=HdtmU3jyHKCgPpjNMeAhCvfagHajGzk9sCsflXDMz3zgJB+dCrUQ194US2jrrBfS4x 5ULODfwnlDybwX8jLHj0+M6wc7Cv79LzF5DtozCvjCmsABS/Y1tz3qpB8a/4Q5TjmQN0 vQMu1Dqq3qESZXUJx4gQ2av/CNNG6nBq2NurIBn4xb7ZwuV3Fpx/MIi/Cgf2J/q5Pq2c CdgafYbRPO8F69+GWFlBPgNiwoAuj4TC+IJVeBaGN0p2l+YOz/lPJb4w2NYadMVK0wKz xUnmkcgGT9rOyioRDpu1k/u59yusFRv6rjSiC8lHcxCQrKSx8iG8Z84iMnp/R6Rlk11p bW9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XokIPBwF; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-86486-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86486-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dm6-20020a170907948600b00a43865ee9f6si458703ejc.22.2024.02.29.01.57.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 01:57:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86486-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XokIPBwF; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-86486-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86486-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AEA2F1F215BB for ; Thu, 29 Feb 2024 09:57:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DEDC6312F; Thu, 29 Feb 2024 09:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="XokIPBwF" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA4E0612D5; Thu, 29 Feb 2024 09:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200582; cv=none; b=IioujxTJOTGdZsl37LSfnd2yFWxMlhe6HabZdaBaxE2GjIXd9j5fhlcvn3HWB+KW2SozhwvPdVoGhJ6ITN9+NRNh/9PM3uy8Nrn7Gh5xKc4+nF8g925x9pFfWDlOotiAbOwPok9xhy5ugH1Q6cIwEUiorZcd9W8h7vVuT3X3af8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200582; c=relaxed/simple; bh=MgdTsHLLMyHVYrpvLWL/9dZ0SjQrrXEvt9AyUFXF49Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=azvBSK34JVxTDOi2MFOEbfBi8Pv6/p32sslrERTHjkc4YvDXvwJSkSdzeSb70u3t/iCR5aYiDG3FHN/HwUXdcYiXGMegCk4wz9SvtIcppEGEjrsTG7W26LeKRPFCpfa9amu1H7SUYUGJLswCW9XQvXfjnFFeSrxFWjxAlo2rbo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=XokIPBwF; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: c817e38cd6e811eeb8927bc1f75efef4-20240229 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=h+/3sZEj2StDKJBFGHkGJp/KMJru0cPHdlEY9qhRQEY=; b=XokIPBwF2r85AdpcHAho1KTg3LwJnJXDALzQi2xuySk5nIkVPMjmoYt+FzhsrULi6/aRdPT8btSYx62TPdi2/deTHk4NoQgDg3Ufm+yiycJR/5gecOX15IZ+dUEX+bgj4xEPGRVOAWDPKayCOzfMT1zzTF8dwrI9KtijMZCPmdo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:e4994c2e-eaf6-4b96-a1af-b027b1aaffdf,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:6f543d0,CLOUDID:580858ff-c16b-4159-a099-3b9d0558e447,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: c817e38cd6e811eeb8927bc1f75efef4-20240229 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1107992247; Thu, 29 Feb 2024 17:56:17 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 29 Feb 2024 17:56:15 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 29 Feb 2024 17:56:14 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , "Yunfei Dong" , , , , , , Subject: [PATCH 3/3] media: mediatek: vcodec: fix h264 stateless decoder smatch warning Date: Thu, 29 Feb 2024 17:56:11 +0800 Message-ID: <20240229095611.6698-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240229095611.6698-1-yunfei.dong@mediatek.com> References: <20240229095611.6698-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--3.129400-8.000000 X-TMASE-MatchedRID: eyg11LmjlNWoft0ZW3r/iTCaEJt46PppPtDsRiRP0d9h2fnHe1cil/Rm 0kmqtH+DgHpD5xuuxKghg4hY1jreIz1/tvmVhm3Z4RtSDjG+z7An8jQhMLowhTb9TB28UbkiGd2 282fApofi8zVgXoAltsIJ+4gwXrEtWBd6ltyXuvvbpmBDD2TFj98wLU+WiG+1nFuFOPWxVkZTG7 xPN4dkvBmdMmsGdter8vvt+3Tm4M/f/vgI7238uvErCCJVJQ9KpuuZawmdJ+KElVGWRzS6/kYFe h7KssddUGjjbmeia+IPZN5fBGmCHKL6Q11UB8yDftwZ3X11IV0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.129400-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: B12C07BBBBE98A45A57C3E4EB857ACB0715509E02DDE7A7912DA0D6CE426E62D2000:8 X-MTK: N X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792226766530022194 X-GMAIL-MSGID: 1792226766530022194 Fix smatch static checker warning for vdec_h264_req_if.c. Leading to kernel crash when fb is NULL. Fixes: 06fa5f757dc5 ("media: mtk-vcodec: vdec: support stateless H.264 decoding") Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c index 5600f1df653d..f1c164b644f8 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_if.c @@ -347,11 +347,16 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, return vpu_dec_reset(vpu); fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); + if (!fb) { + mtk_vdec_err(inst->ctx, "fb buffer is NULL"); + return -EBUSY; + } + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); - y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; - c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + y_fb_dma = (u64)fb->base_y.dma_addr; + c_fb_dma = (u64)fb->base_c.dma_addr; mtk_vdec_debug(inst->ctx, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p", inst->num_nalu, y_fb_dma, c_fb_dma, fb);