Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1258267pxa; Thu, 20 Aug 2020 06:58:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycMn3fklUHyLlFq7CJCD3MfxL6A6gGP0YzStst/vKqiYxrUScM/TUBmvWyCegZ6e6ZJEKu X-Received: by 2002:a50:a165:: with SMTP id 92mr3071505edj.320.1597931887323; Thu, 20 Aug 2020 06:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597931887; cv=none; d=google.com; s=arc-20160816; b=wh6fwY2xWM4oEaRC1HrQHTaxt3Dnyb7JnIuAMjaLG5wNneFKJ1Ti4Sl0uEW7cypLgV uoEzN7aZuZw5zQgcEjnxzpfIR6HcNI9SnNmX1dHTNMZRyCHwmrlR6UIL5jNroCWLpvYs JD/zu57+zTrPA8ZkD/CT86FCbvGydUMAgMEfwopUIZId8s6Tb/q6DA0mLUXd7P+lT63/ Hk8IMnbXwYj4xl2BqxKJepx6N7R9nAHR/i/+lgnVrcufd9KRNz0g2RiC1WgkPOjGF0Kh MFPTn/5VLYsCT6U+aqaHOU2m87yAGecQPUaB5JK0w14qKr3ojFN7U5Ly/RbuT33mGMJR Q2UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YAySZYSCxzj3wVUBQrqtGCHvXByBNysukC5T/HynQPI=; b=ZLwpYImWqrt8fiS27K/jYdB6OBuL7azQK2EcyeRpHi1vgZBwVXzOjswcsZEhY1Fvlu H0H2tpnT3dI1Gm5x39fBBKxvcVP/g7R7/8yQxPIhgkbQzaT6u62XfSMzr2obM7lXzQva Bul5liOAi8PwQzSBUQzo9XOExhyWLh+XRYq3lzIamjvSmd9CET9bA0EBAmnl7Wo14OKg j2bUPquLuA4AipKNXVfvzrqrsS0SeyuJ4gjcyAwD2dJ6zDGz0e6m/ODJ3rF9mkgQxSSn YjTAob04xjkVy//b/qEq8DHv5DINJJj8f8a4aMoOgB2MzPpUbmK3Xl5lR3HGx68tM2Gc HRpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bqaDWSvh; 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 f13si1354714edn.54.2020.08.20.06.57.43; Thu, 20 Aug 2020 06:58:07 -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=bqaDWSvh; 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 S1729371AbgHTN4o (ORCPT + 99 others); Thu, 20 Aug 2020 09:56:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:33620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbgHTJ0D (ORCPT ); Thu, 20 Aug 2020 05:26:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 3E7DD22D2B; Thu, 20 Aug 2020 09:25:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915558; bh=kyZ4OQTGL/UNsZkgR+TRXjK66fbqkC2ATajEKr+L0Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqaDWSvhzAWSzh942EFJzveyD7eJGsIHhpzCBDJWTa/ycein+OzyPJOlDiN+t3D+7 8rG5U08Z/AL61zvk/J9+m5uTyskHo8DAG5dCKDA8yPe5MgoFDXpD/uPNVZPD+rwjVo nZsK+UnuuPB573rntmRvDHqvs2q30/qaKk0D/NUc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugeniu Rosca , Kieran Bingham , Laurent Pinchart , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.8 056/232] media: vsp1: dl: Fix NULL pointer dereference on unbind Date: Thu, 20 Aug 2020 11:18:27 +0200 Message-Id: <20200820091615.499502494@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eugeniu Rosca commit c92d30e4b78dc331909f8c6056c2792aa14e2166 upstream. In commit f3b98e3c4d2e16 ("media: vsp1: Provide support for extended command pools"), the vsp pointer used for referencing the VSP1 device structure from a command pool during vsp1_dl_ext_cmd_pool_destroy() was not populated. Correctly assign the pointer to prevent the following null-pointer-dereference when removing the device: [*] h3ulcb-kf #> echo fea28000.vsp > /sys/bus/platform/devices/fea28000.vsp/driver/unbind Unable to handle kernel NULL pointer dereference at virtual address 0000000000000028 Mem abort info: ESR = 0x96000006 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000006 CM = 0, WnR = 0 user pgtable: 4k pages, 48-bit VAs, pgdp=00000007318be000 [0000000000000028] pgd=00000007333a1003, pud=00000007333a6003, pmd=0000000000000000 Internal error: Oops: 96000006 [#1] PREEMPT SMP Modules linked in: CPU: 1 PID: 486 Comm: sh Not tainted 5.7.0-rc6-arm64-renesas-00118-ge644645abf47 #185 Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT) pstate: 40000005 (nZcv daif -PAN -UAO) pc : vsp1_dlm_destroy+0xe4/0x11c lr : vsp1_dlm_destroy+0xc8/0x11c sp : ffff800012963b60 x29: ffff800012963b60 x28: ffff0006f83fc440 x27: 0000000000000000 x26: ffff0006f5e13e80 x25: ffff0006f5e13ed0 x24: ffff0006f5e13ed0 x23: ffff0006f5e13ed0 x22: dead000000000122 x21: ffff0006f5e3a080 x20: ffff0006f5df2938 x19: ffff0006f5df2980 x18: 0000000000000003 x17: 0000000000000000 x16: 0000000000000016 x15: 0000000000000003 x14: 00000000000393c0 x13: ffff800011a5ec18 x12: ffff800011d8d000 x11: ffff0006f83fcc68 x10: ffff800011a53d70 x9 : ffff8000111f3000 x8 : 0000000000000000 x7 : 0000000000210d00 x6 : 0000000000000000 x5 : ffff800010872e60 x4 : 0000000000000004 x3 : 0000000078068000 x2 : ffff800012781000 x1 : 0000000000002c00 x0 : 0000000000000000 Call trace: vsp1_dlm_destroy+0xe4/0x11c vsp1_wpf_destroy+0x10/0x20 vsp1_entity_destroy+0x24/0x4c vsp1_destroy_entities+0x54/0x130 vsp1_remove+0x1c/0x40 platform_drv_remove+0x28/0x50 __device_release_driver+0x178/0x220 device_driver_detach+0x44/0xc0 unbind_store+0xe0/0x104 drv_attr_store+0x20/0x30 sysfs_kf_write+0x48/0x70 kernfs_fop_write+0x148/0x230 __vfs_write+0x18/0x40 vfs_write+0xdc/0x1c4 ksys_write+0x68/0xf0 __arm64_sys_write+0x18/0x20 el0_svc_common.constprop.0+0x70/0x170 do_el0_svc+0x20/0x80 el0_sync_handler+0x134/0x1b0 el0_sync+0x140/0x180 Code: b40000c2 f9403a60 d2800084 a9400663 (f9401400) ---[ end trace 3875369841fb288a ]--- Fixes: f3b98e3c4d2e16 ("media: vsp1: Provide support for extended command pools") Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Eugeniu Rosca Reviewed-by: Kieran Bingham Tested-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/vsp1/vsp1_dl.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/media/platform/vsp1/vsp1_dl.c +++ b/drivers/media/platform/vsp1/vsp1_dl.c @@ -431,6 +431,8 @@ vsp1_dl_cmd_pool_create(struct vsp1_devi if (!pool) return NULL; + pool->vsp1 = vsp1; + spin_lock_init(&pool->lock); INIT_LIST_HEAD(&pool->free);