Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp299654pxx; Wed, 28 Oct 2020 05:21:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGqZoNBPfA+80tfQPhQK/z6/5yTR98S3x9M/VXkrG8An19NnW583mOJh+eZe9gFE/mcXnF X-Received: by 2002:a05:6402:651:: with SMTP id u17mr7224785edx.206.1603887668835; Wed, 28 Oct 2020 05:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887668; cv=none; d=google.com; s=arc-20160816; b=DuNyT1nWjBT+HbhU72BynhgY4HdhrTbaklrh/APoZMr7yTS7n1I9x5kfJ9i6ePxCf/ 8EL1Jt/BhmqqgEj0gXmp2hDO1QHKDhHZmohJNkWMYVio4/MjoI0cy415ytsNjBrrEFrJ p9uS+R723bQC7VwHQyUkbOIlPZJvUH99vouTXoiWdeG+IB9JxePspqnYZRdONg5pRfBL 2OCbMK5DPGrVB6cLD/IoBHN6v+MKfPBdfZfT3jcdh0a15KwYc0Ovoz1ulZDM6wXUHx1z 48bdEDXHgCuqwK8uSAbz/2RUXbzS9illlXve+wpSH8GtoyPyKUa/RNCxM+Ik1D5kvw9t PCpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M+BDa+Rx6Cqzr78Aq6s+NbGCpLK0sVtsnqmX8f/5SsU=; b=BP/WbDheL0CmMD8kqPtggzVlYN0/6PtK0fNqb1xtwQQeYSW/Zcpp7ZJuWWavUQMedx c+24eN+9tqOdoH7fffzBPri8SgxyIcJA9qtMbIkKfwKJXwbie6ABAhZw5A9YbOys7Q3E qvRPDftuyE2XG0BH7Rlc+deCzESZXQudViQfxZGR1gXSAfZiXSu0y1TSNj7+Ab7zm9XZ FG7z4kbF9gW4sErRJGYunshBT/YrhWpr94ANAWWsV8s+Pj13tQizC2Bt77c3LYG8Ifq4 PrYijOXi3THoauWtmJjjOCljRJcpY/61dLHxcCGy2ou/SxtLLU85tZIUucv9ROL4XRX3 4hVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dh+kJwyB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si2698178edr.173.2020.10.28.05.20.46; Wed, 28 Oct 2020 05:21:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dh+kJwyB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1796514AbgJ0PTJ (ORCPT + 99 others); Tue, 27 Oct 2020 11:19:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:51932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1795042AbgJ0PO5 (ORCPT ); Tue, 27 Oct 2020 11:14:57 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 830F220728; Tue, 27 Oct 2020 15:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811696; bh=+m6xu3aGhCkPp0WNGUiov9exqKq/HXvY0saNarZFAsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dh+kJwyBu6AQ9K4CtFYGZnoDx7eRhxMWQ7bw1oX2dr4Ri1759Mj7r8zTtjEVHHNqJ r7fXXbvwYoz4oB4YrCevb8/4MZbYk454oF2bYEbFXkWOR+1fM0ZEXA1ei8kBg4LK6e eLRnW+ca1WsW9Owplexvt/txZ4VISO3E5fZX31pE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vikash Garodia , Fritz Koenig , Stanimir Varbanov , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.8 553/633] media: venus: fixes for list corruption Date: Tue, 27 Oct 2020 14:54:56 +0100 Message-Id: <20201027135548.744465259@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vikash Garodia [ Upstream commit e1c69c4eef61ffe295b747992c6fd849e6cd747d ] There are few list handling issues while adding and deleting node in the registered buf list in the driver. 1. list addition - buffer added into the list during buf_init while not deleted during cleanup. 2. list deletion - In capture streamoff, the list was reinitialized. As a result, if any node was present in the list, it would lead to issue while cleaning up that node during buf_cleanup. Corresponding call traces below: [ 165.751014] Call trace: [ 165.753541] __list_add_valid+0x58/0x88 [ 165.757532] venus_helper_vb2_buf_init+0x74/0xa8 [venus_core] [ 165.763450] vdec_buf_init+0x34/0xb4 [venus_dec] [ 165.768271] __buf_prepare+0x598/0x8a0 [videobuf2_common] [ 165.773820] vb2_core_qbuf+0xb4/0x334 [videobuf2_common] [ 165.779298] vb2_qbuf+0x78/0xb8 [videobuf2_v4l2] [ 165.784053] v4l2_m2m_qbuf+0x80/0xf8 [v4l2_mem2mem] [ 165.789067] v4l2_m2m_ioctl_qbuf+0x2c/0x38 [v4l2_mem2mem] [ 165.794624] v4l_qbuf+0x48/0x58 [ 1797.556001] Call trace: [ 1797.558516] __list_del_entry_valid+0x88/0x9c [ 1797.562989] vdec_buf_cleanup+0x54/0x228 [venus_dec] [ 1797.568088] __buf_prepare+0x270/0x8a0 [videobuf2_common] [ 1797.573625] vb2_core_qbuf+0xb4/0x338 [videobuf2_common] [ 1797.579082] vb2_qbuf+0x78/0xb8 [videobuf2_v4l2] [ 1797.583830] v4l2_m2m_qbuf+0x80/0xf8 [v4l2_mem2mem] [ 1797.588843] v4l2_m2m_ioctl_qbuf+0x2c/0x38 [v4l2_mem2mem] [ 1797.594389] v4l_qbuf+0x48/0x58 Signed-off-by: Vikash Garodia Reviewed-by: Fritz Koenig Signed-off-by: Stanimir Varbanov Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/qcom/venus/vdec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 7c4c483d54389..76be14efbfb09 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1088,8 +1088,6 @@ static int vdec_stop_capture(struct venus_inst *inst) break; } - INIT_LIST_HEAD(&inst->registeredbufs); - return ret; } @@ -1189,6 +1187,14 @@ static int vdec_buf_init(struct vb2_buffer *vb) static void vdec_buf_cleanup(struct vb2_buffer *vb) { struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct venus_buffer *buf = to_venus_buffer(vbuf); + + mutex_lock(&inst->lock); + if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + if (!list_empty(&inst->registeredbufs)) + list_del_init(&buf->reg_list); + mutex_unlock(&inst->lock); inst->buf_count--; if (!inst->buf_count) -- 2.25.1