From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D895DC433ED for ; Sat, 10 Apr 2021 05:59:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9985E61185 for ; Sat, 10 Apr 2021 05:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233606AbhDJF71 (ORCPT ); Sat, 10 Apr 2021 01:59:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:44880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbhDJF70 (ORCPT ); Sat, 10 Apr 2021 01:59:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25F0A61184; Sat, 10 Apr 2021 05:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618034352; bh=bGAq0jJsJME+jNzgXtR79hH1aKAjwoQdk5TEs0lc5t0=; h=Subject:To:From:Date:From; b=vRgJHHx03g7HfvGuMV3mRi7mrrtWnMT/jc3HHeJXKWIa2FX8g1fUN5j92q/NTSksQ Z9xlZf5R27xiF3PJXsfjegySwfhXiNkHF3lKy3ATh8rovcd++ubehs8LgApeCNVNpV xnFVE1P4Wt29STWk6fmzohf8pR17bQnnHa9ztS/4= Subject: patch "usb: roles: Call try_module_get() from" added to usb-next To: hdegoede@redhat.com, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, linux@roeck-us.net, stable@vger.kernel.org From: Date: Sat, 10 Apr 2021 07:58:15 +0200 Message-ID: <1618034295178203@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is a note to let you know that I've just added the patch titled usb: roles: Call try_module_get() from to my usb git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git in the usb-next branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will also be merged in the next major kernel release during the merge window. If you have any questions about this process, please let me know. >From 3a2a91a2d51761557843996a66098eb7182b48b4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 9 Apr 2021 14:41:36 +0200 Subject: usb: roles: Call try_module_get() from usb_role_switch_find_by_fwnode() usb_role_switch_find_by_fwnode() returns a reference to the role-switch which must be put by calling usb_role_switch_put(). usb_role_switch_put() calls module_put(sw->dev.parent->driver->owner), add a matching try_module_get() to usb_role_switch_find_by_fwnode(), making it behave the same as the other usb_role_switch functions which return a reference. This avoids a WARN_ON being hit at kernel/module.c:1158 due to the module-refcount going below 0. Fixes: c6919d5e0cd1 ("usb: roles: Add usb_role_switch_find_by_fwnode()") Cc: stable Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210409124136.65591-1-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/roles/class.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index 97f37077b7f9..33b637d0d8d9 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -189,6 +189,8 @@ usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode) return NULL; dev = class_find_device_by_fwnode(role_class, fwnode); + if (dev) + WARN_ON(!try_module_get(dev->parent->driver->owner)); return dev ? to_role_switch(dev) : NULL; } -- 2.31.1