Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp633527iog; Mon, 13 Jun 2022 09:33:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sjSUyVFzAL+TedQsCKHy8NGEg+cgK1fJyPLsVRr7rDByAj8X553h0gezeBgkXxxdRQD4Pw X-Received: by 2002:a17:90b:1bd0:b0:1e8:9ac9:c3ec with SMTP id oa16-20020a17090b1bd000b001e89ac9c3ecmr619776pjb.117.1655137985637; Mon, 13 Jun 2022 09:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137985; cv=none; d=google.com; s=arc-20160816; b=VBTSn9lm3PHxpB/EwP09pbfmKg1srIJmMRiyAsse0lXuA7mg1hxQWLwLx72Ti0rZa6 zBC7VLuwPAV9iJSu2IFW2P4Js53t7GScv9NEqB5bnHi5ltdB3t5GV/r4URAdeeD1JWBu 9skq4yu1n1GodEVbUHIa7rpP4mB+xM7nYPNJy4AghfMMHDo6cTlCS1YZEi33Fq9mG5NE 0eg9d6JsyIGLIirxcrr0y7uVqh17MY+RFkOuzdyiGnwXgzypIkRWFFSIJcTcAqdy5wIP Gl1fjdmerD+orhCfFA1CjOmosIba81WfhhSniTXoDPqaF/nC73bCy2sGtrv4yNjCBppJ YtsA== 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=fEMliVDx6KkF4rhCSZ2OJ8ujr/pXwq654TD8FDaUsGA=; b=nigbs7YkuIjAho2cgqb0SKU1fOXEant6mWOEchYPxeqbWcFZfdlHYTnqX2jmlCo+mq wbpIb3WmVHWB+fObxRK1Ye2C6kmVWw1+HBuDWxfmQcLWbYDN/jP3A+PNxIPfPStMDaz1 nFF3OrzLViIL2sbBYW7oH87lIKHocyCUeot6cmd5GQP2A0hu5yv3v1in6kxAadN0tfQR bVfmZ48VHLDpuFmYq5F7pnXccSSHSnvPp0U7kNdRDT25KPEAam9cTWdRq6ynUgxh2Wzk VrzDQ0lRk0jhuBnMdxoyWoFMxE/lCDND1+AYJFXeHLmiVaoq0326LoE5GX0Vupu4GY+1 6mVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qZTDZY4I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a62c102000000b0051c28de280fsi8934414pfg.346.2022.06.13.09.32.53; Mon, 13 Jun 2022 09:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qZTDZY4I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1352447AbiFMMU5 (ORCPT + 99 others); Mon, 13 Jun 2022 08:20:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357121AbiFMMTV (ORCPT ); Mon, 13 Jun 2022 08:19:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2976E562DB; Mon, 13 Jun 2022 04:02:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 957EDB80D31; Mon, 13 Jun 2022 11:02:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 012C8C3411C; Mon, 13 Jun 2022 11:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655118167; bh=cO+MlwZPZfzLK6MD1rKEn5/lcgTLQLFpZ1PoZlE/mYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZTDZY4IcJvk5r+eMbcMu7prnT8SlONqceg92rnfGQ9ZEsKAzebYdorcn4uwsKR10 46sn8v4G2ICguoxcyokCDIJrf+/AkP1Mjjcx4+ks6GMmz9X31Inhh1Ylb3Xt3ladSW H/jb1OdC9RZ9kRry1hRIIlO/rEkwSqkwk4TEsYY4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Slaby , Zheyu Ma , Sasha Levin Subject: [PATCH 4.19 250/287] tty: synclink_gt: Fix null-pointer-dereference in slgt_clean() Date: Mon, 13 Jun 2022 12:11:14 +0200 Message-Id: <20220613094931.595883256@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094923.832156175@linuxfoundation.org> References: <20220613094923.832156175@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheyu Ma [ Upstream commit 689ca31c542687709ba21ec2195c1fbce34fd029 ] When the driver fails at alloc_hdlcdev(), and then we remove the driver module, we will get the following splat: [ 25.065966] general protection fault, probably for non-canonical address 0xdffffc0000000182: 0000 [#1] PREEMPT SMP KASAN PTI [ 25.066914] KASAN: null-ptr-deref in range [0x0000000000000c10-0x0000000000000c17] [ 25.069262] RIP: 0010:detach_hdlc_protocol+0x2a/0x3e0 [ 25.077709] Call Trace: [ 25.077924] [ 25.078108] unregister_hdlc_device+0x16/0x30 [ 25.078481] slgt_cleanup+0x157/0x9f0 [synclink_gt] Fix this by checking whether the 'info->netdev' is a null pointer first. Reviewed-by: Jiri Slaby Signed-off-by: Zheyu Ma Link: https://lore.kernel.org/r/20220410114814.3920474-1-zheyuma97@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/synclink_gt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index afe34beec720..11c62fcd67f2 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -1753,6 +1753,8 @@ static int hdlcdev_init(struct slgt_info *info) */ static void hdlcdev_exit(struct slgt_info *info) { + if (!info->netdev) + return; unregister_hdlc_device(info->netdev); free_netdev(info->netdev); info->netdev = NULL; -- 2.35.1