Received: by 10.192.165.156 with SMTP id m28csp60711imm; Tue, 10 Apr 2018 16:23:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx49nuA7CgSw1XCghY+6HKQBZY3GnVyQnt0s2PpFQrzH+NokEY6s3mCiYYVRX1CMyqVCD07gF X-Received: by 10.98.13.23 with SMTP id v23mr1971582pfi.202.1523402634899; Tue, 10 Apr 2018 16:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402634; cv=none; d=google.com; s=arc-20160816; b=UYgT3Ibu5pfmoRaRUPMssoEqlU16QXC52GszCtvNSXt4zM4BQHMLKy4dIaZXNnxPxu YyWjGlER+LS6sXOEm0Q+A1GXhp927e1G41ToZ4XKxPOSchJa2NQPUjf+MFWHUP3npLDy sc0ElSnz7bIichw8LITi/K+ya/EEYDFHqT7tih6Vsmr/jqdfKEQDjhyiqdXJhraMnln4 cGEzk5QR++hLVN2XxM+sOUmmfKSAilLSC86t9E4Flln78G53wc98/FGJDYKfAowNpJ3c HrqqjBG0k6/U9ZdRb6xUYFAA198Ta14OmNu02E71mNFAEpiH9AIWsl9wf2Db1BSdYQrm PRAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4mjljQKNgwViFTHl0J0DW6WDMeBh19PEYRgWbzTnhpA=; b=ptviBYw7uRC0hqkGK+9AmJwMBI0KpA4X4DlJAtNRV6AeiJRVKNG20uDuOsDzpTLyM6 b1WZAHrQUejbNfcWjO3CxiQa0i+kFizjeWWSewNQ4XTOEEGWtlWkhlPmgc9Q6lCHPisM wof4yluqpGf3lnzLbY0l7DbblpjX0W7gkt9e5LgIm63eyOyUWLfQxwHjINaG3jbRhQ9t JXjmJHR4O3N8VJpYNxTZD3ZjXQ3qJyYAS4Wgpmqh0BI6lhTmSBjaa5+HUPPciyqx+2nB xV0Qmk8xFwchj9jL2KXiAwWRJPIfLSlohNfHmB402Gs50bxV392KMiCDecf4uG0zmA5y tbHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si2819456pff.211.2018.04.10.16.23.18; Tue, 10 Apr 2018 16:23:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754794AbeDJWbX (ORCPT + 99 others); Tue, 10 Apr 2018 18:31:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40340 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754763AbeDJWbU (ORCPT ); Tue, 10 Apr 2018 18:31:20 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E4CE6DF6; Tue, 10 Apr 2018 22:31:19 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Raghuram Chary J , "David S. Miller" Subject: [PATCH 4.15 123/168] lan78xx: Crash in lan78xx_writ_reg (Workqueue: events lan78xx_deferred_multicast_write) Date: Wed, 11 Apr 2018 00:24:25 +0200 Message-Id: <20180410212805.809495859@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Raghuram Chary J [ Upstream commit 2d2d99ec13f62d5d2cecb6169dfdb6bbe05356d0 ] Description: Crash was reported with syzkaller pointing to lan78xx_write_reg routine. Root-cause: Proper cleanup of workqueues and init/setup routines was not happening in failure conditions. Fix: Handled the error conditions by cleaning up the queues and init/setup routines. Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Reported-by: Andrey Konovalov Signed-off-by: Raghuram Chary J Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/lan78xx.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2863,8 +2863,7 @@ static int lan78xx_bind(struct lan78xx_n if (ret < 0) { netdev_warn(dev->net, "lan78xx_setup_irq_domain() failed : %d", ret); - kfree(pdata); - return ret; + goto out1; } dev->net->hard_header_len += TX_OVERHEAD; @@ -2872,14 +2871,32 @@ static int lan78xx_bind(struct lan78xx_n /* Init all registers */ ret = lan78xx_reset(dev); + if (ret) { + netdev_warn(dev->net, "Registers INIT FAILED...."); + goto out2; + } ret = lan78xx_mdio_init(dev); + if (ret) { + netdev_warn(dev->net, "MDIO INIT FAILED....."); + goto out2; + } dev->net->flags |= IFF_MULTICAST; pdata->wol = WAKE_MAGIC; return ret; + +out2: + lan78xx_remove_irq_domain(dev); + +out1: + netdev_warn(dev->net, "Bind routine FAILED"); + cancel_work_sync(&pdata->set_multicast); + cancel_work_sync(&pdata->set_vlan); + kfree(pdata); + return ret; } static void lan78xx_unbind(struct lan78xx_net *dev, struct usb_interface *intf) @@ -2891,6 +2908,8 @@ static void lan78xx_unbind(struct lan78x lan78xx_remove_mdio(dev); if (pdata) { + cancel_work_sync(&pdata->set_multicast); + cancel_work_sync(&pdata->set_vlan); netif_dbg(dev, ifdown, dev->net, "free pdata"); kfree(pdata); pdata = NULL;