Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp438034iog; Mon, 13 Jun 2022 06:02:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd6NYr6VjHruL/2KolmZH7lx8PAbPwhpY9iVJFjHr2FHA0IiHu7/VU1oczZw61RtSJTLQ+ X-Received: by 2002:aa7:d88a:0:b0:431:32be:f2d4 with SMTP id u10-20020aa7d88a000000b0043132bef2d4mr50011942edq.360.1655125339638; Mon, 13 Jun 2022 06:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125339; cv=none; d=google.com; s=arc-20160816; b=DfnYQRuQ8zgYt3LHUYnIFqt8NgnpLjglSxzb4HK7/gb051eMzV9xZrfgjBspO4FLtl hPFQhUx9exwtb1+fMYfmURYs/Gp0OUS6FI7d+yTdGqVA369E9hJeTMTOSuh9G/mnDA6g 0MRJNt3Tug5cPYuJty4p7ztk02FAR/Nbdrb8T3Ba5Mo2UixMuD3KAfmJxVBDbYR8qQpN xfzuQGN3uUi1876J39VIrZs3OhoL+S2rewh5fFJO1+Fe2EK3P2cJuZdVxPFTxnVI+T1i OP/IFSWlnxtfvTS1fDMO87QwILVWY3PEX4jq8cRizPYbwqIEVqdlNN2mZoS8XiZK6i4l SLbA== 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=8zQHO/JGavvMlKuBdwSkNoi2RvYxKgYTQRyFgpZDmZc=; b=JeFt7rc89BLU3RVpcrpZxI7cCuyU8IGCrvJYQsGq4KJCTgYBqFhHfO1oh7VNDBhPe2 shKOG5qMr99QEhPTnjS/4k3brFl2sZiqgsWVhWV7o7RjWG0C784ZhTS/y2gMiem6TqbJ UDtmOGS5cv2UKQWMxohgzbMgpRuInz81Fl9uR7Y8yiVMTPs5BHkUleiEYvgllB9DYNso +zHRF2PQzMDKYMR169+34enTVFhjn/StouMd0EnKmxVm9AlVXQo7bX+K4WDZrw7IbyZE qADF1uw4hnk8ieQBKa+jh5bF1oupUJDQiUI5oPpzvXaSLOedA5DDhxASHLLMGbP6sSNp IK7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EHWwlsf7; 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 c13-20020a1709063f0d00b006fea42b2e6fsi8013040ejj.642.2022.06.13.06.01.51; Mon, 13 Jun 2022 06:02:19 -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=EHWwlsf7; 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 S1355996AbiFMLrk (ORCPT + 99 others); Mon, 13 Jun 2022 07:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356430AbiFMLod (ORCPT ); Mon, 13 Jun 2022 07:44:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8980147385; Mon, 13 Jun 2022 03:50:46 -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 BBF3EB80D41; Mon, 13 Jun 2022 10:50:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A1DAC34114; Mon, 13 Jun 2022 10:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117438; bh=r7AE4TyLCHPSD38SysrDQyTnu+TvKZGuaaI/tTppefc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EHWwlsf7Eo/f1cPe0m3Lv8sgRpMmI5PlERUWhUv5RSRxH9Yy3/EeRyIQe6F9YGmz/ msbkaHzyWjeMj7s8DmW0BqufQHdJ67RsRQIQqFRP/3vhjGGFj8hVADXCwclXbOp0S6 B/5aH02EzpTLM5ZmODU/scukuJn0UpgcNBTrWiv0= 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 5.4 368/411] tty: synclink_gt: Fix null-pointer-dereference in slgt_clean() Date: Mon, 13 Jun 2022 12:10:41 +0200 Message-Id: <20220613094939.719478900@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=unavailable 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 ff345a8e0fcc..b72471373c71 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -1752,6 +1752,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