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=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 10035C282C4 for ; Sat, 9 Feb 2019 16:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D40AB21773 for ; Sat, 9 Feb 2019 16:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbfBIQYW convert rfc822-to-8bit (ORCPT ); Sat, 9 Feb 2019 11:24:22 -0500 Received: from smtp-prod04.osg.ufl.edu ([128.227.74.220]:34934 "EHLO smtp.ufl.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726880AbfBIQYW (ORCPT ); Sat, 9 Feb 2019 11:24:22 -0500 X-UFL-GatorLink-Authenticated: authenticated as () with from 10.36.197.40 Received: from exmbxprd19.ad.ufl.edu ([10.36.197.40]) by smtp.ufl.edu (8.14.4/8.14.4/3.0.0) with ESMTP id x19GOKUX006657 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT) for ; Sat, 9 Feb 2019 11:24:20 -0500 Received: from exmbxprd18.ad.ufl.edu (10.36.197.39) by exmbxprd19.ad.ufl.edu (10.36.197.40) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 9 Feb 2019 11:24:20 -0500 Received: from exmbxprd18.ad.ufl.edu ([fe80::890c:cba5:27b2:db27]) by exmbxprd18.ad.ufl.edu ([fe80::890c:cba5:27b2:db27%19]) with mapi id 15.00.1395.000; Sat, 9 Feb 2019 11:24:20 -0500 From: "Yavuz, Tuba" To: "netdev@vger.kernel.org" Subject: [PATCH] net: hso: do not unregister if not registered Thread-Topic: [PATCH] net: hso: do not unregister if not registered Thread-Index: AQHUwJPoSTc4WpiIzEyFKtYBOqLlqg== Date: Sat, 9 Feb 2019 16:24:20 +0000 Message-ID: <89a423a522834affadda4aaf7ab4d333@exmbxprd18.ad.ufl.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.36.198.11] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-09_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=882 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902090120 X-UFL-Spam-Level: * Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On an error path inside the hso_create_net_device function of the hso driver, hso_free_net_device gets called. This causes potentially a negative reference count in the net device if register_netdev has not been called yet as hso_free_net_device calls unregister_netdev regardless. I think the driver should distinguish these cases and call unregister_netdev only if register_netdev has been called. Signed-off-by: Tuba Yavuz --- --- linux-stable/drivers/net/usb/hso.c.orig 2019-01-27 14:45:58.232683119 -0500 +++ linux-stable/drivers/net/usb/hso.c 2019-02-05 17:54:17.056496019 -0500 @@ -2377,7 +2377,9 @@ static void hso_free_net_device(struct h remove_net_device(hso_net->parent); - if (hso_net->net) + if (hso_net->net && + hso_net->net->reg_state == NETREG_REGISTERED) unregister_netdev(hso_net->net); /* start freeing */