]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
usb: roles: fix a potential use after free
authorWen Yang <wenyang@linux.alibaba.com>
Sun, 24 Nov 2019 14:22:36 +0000 (22:22 +0800)
committerSeth Forshee <seth.forshee@canonical.com>
Mon, 6 Jan 2020 13:29:13 +0000 (07:29 -0600)
commit6cdf83b09631d2d3ea64a530eff3637b7d489d23
tree1bcc4ca5a21fca56601666be6e459d2a7905233d
parentaddce86f5f8e7057cb9b504810f168b4f58d7df0
usb: roles: fix a potential use after free

BugLink: https://bugs.launchpad.net/bugs/1858424
commit 1848a543191ae32e558bb0a5974ae7c38ebd86fc upstream.

Free the sw structure only after we are done using it.
This patch just moves the put_device() down a bit to avoid the
use after free.

Fixes: 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting")
Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Cc: stable <stable@vger.kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/20191124142236.25671-1-wenyang@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/usb/roles/class.c