From nobody Wed Dec 31 15:02:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A083CC4332F for ; Wed, 1 Nov 2023 13:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344288AbjKANf5 (ORCPT ); Wed, 1 Nov 2023 09:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344267AbjKANfz (ORCPT ); Wed, 1 Nov 2023 09:35:55 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86E410C; Wed, 1 Nov 2023 06:35:49 -0700 (PDT) Received: from dggpemm500011.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SL7LT2QCqzVlG4; Wed, 1 Nov 2023 21:35:45 +0800 (CST) Received: from huawei.com (10.175.104.170) by dggpemm500011.china.huawei.com (7.185.36.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 1 Nov 2023 21:35:46 +0800 From: Ren Mingshuai To: CC: , , , , , , , Subject: [PATCH] tty: hso: Fix potential null pointer dereference Date: Wed, 1 Nov 2023 21:35:44 +0800 Message-ID: <20231101133544.246961-1-renmingshuai@huawei.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500011.china.huawei.com (7.185.36.110) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Generally, the old always points to the address of a ktermios structure, so old is unlikely to be NULL. Still check it before dereference as elsewhere. Signed-off-by: Ren Mingshuai --- drivers/net/usb/hso.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index ce1f6081d582..4ad829ab54d3 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -1396,7 +1396,8 @@ static void hso_serial_set_termios(struct tty_struct = *tty, if (serial->port.count) _hso_serial_set_termios(tty); else - tty->termios =3D *old; + if (old) + tty->termios =3D *old; spin_unlock_irqrestore(&serial->serial_lock, flags); =20 /* done */ --=20 2.33.0