Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3038276pxb; Mon, 18 Oct 2021 07:05:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2kDJdyMSwm9gFELOVFJZ0pm/b9xRzkzwWoDcOhlUPjvA0d1DaFYoFbISG55Lm5itRVdQH X-Received: by 2002:a17:90a:f292:: with SMTP id fs18mr32715442pjb.229.1634565944434; Mon, 18 Oct 2021 07:05:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565944; cv=none; d=google.com; s=arc-20160816; b=BYYm0tA9HroN2dxAnjQjLFLNN8P1GDIY7Nkfe4Wj4OGTSUoQZlFqv3M0DOeZYQD0/9 g7nD1xA2F24kljg/+H3K5UnFsvz7WCPY8I1L8NHd1tsXQ0hFkae9bYP9rDHaHmUR0FOS v98Cwn5+CEGKfFcOSMejwEq+Z/6MXkB1KMTPiGrzl+W7CMndA4nwP6W/S6kfLNJR/tBa jdPiFi7slzwN3OBOhaT1vsoJkgQOvbDfVMDzQ2276lpmWNGPLOVrYHxKupHQzSu+BZn0 QEBLNE0muSja4HfjRv5nWjWC4aNZkk0YdS0JkE+swtyVXIFQLxeLsEXIvhl6eTwDMC35 fFyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CoOz6uqIbt2sXteOLgwv6bhbV0/SOfZAZiUmxh9VwIY=; b=lPyZuDDQk+VJ/uufi5w+5ZE9JSCvL21bEqqF29bUhmtxbnsUgU8uKIKMW0pbOgEisM 9mG9dQpLyZ5G621VWAksjSXvcNaG4wPd744TRWEFmyFW/PHwTu5M+lrPfPSmIevYwp/m Y2axGL6J6Upa5i8jedwtwQ4JgBSIPz6gOy831JirNeN0VdiuNTDo/V6fq808WMx/JyOT y+E61vrsfIQA6sTXvjnHiVW1JnqETjrAg5JzCosc0MifrDXrVSy1feyCCOzpUOqz22YB 1Jp8z9ksB49FCiPCudb4KMc+7oCJ/KqlavGzurD69NkxvskkLZOWM2ywhAHLm/BY4nh4 BnVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ks/X0oIN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t31si22301789pfg.142.2021.10.18.07.05.29; Mon, 18 Oct 2021 07:05:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ks/X0oIN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232458AbhJROFo (ORCPT + 99 others); Mon, 18 Oct 2021 10:05:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:37464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234170AbhJROB5 (ORCPT ); Mon, 18 Oct 2021 10:01:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B545B613B3; Mon, 18 Oct 2021 13:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564579; bh=wl6BZ4CiyNR380+3hmLrpZ/UsCdaPZpusfSZCKKUSUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ks/X0oINv4OS+jhdRhImf6b0BYI0uDULzNG1T6v94j7uVovKSSFzV/USIhSubjXJs WV2wZWkVg+yTT0mVLEnsN21vSZoAk/KrikyPh3mLvnlZZn6oxObj8fQ1Xejwwo8Xas e7O0NKJCNzRODC3t6o/WA9Tr1B4OjyA+A9ypKgFg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arun Ramadoss , "David S. Miller" Subject: [PATCH 5.14 110/151] net: dsa: microchip: Added the condition for scheduling ksz_mib_read_work Date: Mon, 18 Oct 2021 15:24:49 +0200 Message-Id: <20211018132344.249261516@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arun Ramadoss commit ef1100ef20f29aec4e62abeccdb5bdbebba1e378 upstream. When the ksz module is installed and removed using rmmod, kernel crashes with null pointer dereferrence error. During rmmod, ksz_switch_remove function tries to cancel the mib_read_workqueue using cancel_delayed_work_sync routine and unregister switch from dsa. During dsa_unregister_switch it calls ksz_mac_link_down, which in turn reschedules the workqueue since mib_interval is non-zero. Due to which queue executed after mib_interval and it tries to access dp->slave. But the slave is unregistered in the ksz_switch_remove function. Hence kernel crashes. To avoid this crash, before canceling the workqueue, resetted the mib_interval to 0. v1 -> v2: -Removed the if condition in ksz_mib_read_work Fixes: 469b390e1ba3 ("net: dsa: microchip: use delayed_work instead of timer + work") Signed-off-by: Arun Ramadoss Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/microchip/ksz_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -449,8 +449,10 @@ EXPORT_SYMBOL(ksz_switch_register); void ksz_switch_remove(struct ksz_device *dev) { /* timer started */ - if (dev->mib_read_interval) + if (dev->mib_read_interval) { + dev->mib_read_interval = 0; cancel_delayed_work_sync(&dev->mib_read); + } dev->dev_ops->exit(dev); dsa_unregister_switch(dev->ds);