[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191125093528.GC20079@b29397-desktop>
Date: Mon, 25 Nov 2019 09:35:30 +0000
From: Peter Chen <peter.chen@....com>
To: Wen Yang <wenyang@...ux.alibaba.com>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Hans de Goede <hdegoede@...hat.com>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] usb: roles: fix a potential use after free
On 19-11-24 22:22:36, Wen Yang wrote:
> 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@...ux.alibaba.com>
> Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> Cc: Hans de Goede <hdegoede@...hat.com>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: Chunfeng Yun <chunfeng.yun@...iatek.com>
> Cc: Suzuki K Poulose <suzuki.poulose@....com>
> Cc: linux-usb@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> ---
> drivers/usb/roles/class.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index 8273126..63a00ff 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -169,8 +169,8 @@ struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *fwnode)
> void usb_role_switch_put(struct usb_role_switch *sw)
> {
> if (!IS_ERR_OR_NULL(sw)) {
> - put_device(&sw->dev);
> module_put(sw->dev.parent->driver->owner);
> + put_device(&sw->dev);
> }
> }
> EXPORT_SYMBOL_GPL(usb_role_switch_put);
> --
> 1.8.3.1
>
Reviewed-by: Peter Chen <peter.chen@....com>
--
Thanks,
Peter Chen
Powered by blists - more mailing lists