Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp102158rdb; Wed, 1 Nov 2023 19:09:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsnLIHymcVFm1aaXZqYC9CsHihjQiWEr3c5gGcxCM6/ExBSip+x6ZhSVBuprXBnKsigE6/ X-Received: by 2002:a05:6808:210e:b0:3a1:e17a:b3fb with SMTP id r14-20020a056808210e00b003a1e17ab3fbmr22826839oiw.1.1698890974168; Wed, 01 Nov 2023 19:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698890974; cv=none; d=google.com; s=arc-20160816; b=boAHKN57XWSlVOYZhYsIG87vBTWtvAY2y/8MvuIWA1sFsdVg0kF1oti57LX9UQsMTl locj+UKWTm0H6grstcP+UF0XfFGLTJ8ODN6ufs2HGHeXJ139sNKZfJS8Tz190R9tLA7/ XkS1Jo/Ow8R+3tr5DeiCa7UVWEQjNvAW7UC33rbw2YLKDk3rIKwvLiHCVhkdhXzYXmVi Qhlho0fa9DCxQQVt8CvppRpg7Wb9N5BrRA4sWcg4HJFtjrjuyUB5zRKT8uQN8ci5pLdO VC2oDxkyJO0lFpaGDTg4dWl6agTcmbovcv/U9Ndjd8Wx8iTo8+gYrnpDx4XiOLWbHD1j g+Pg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Jq3QE8QKQwHaePhjM+/X1+84aYUAhFYBHXRJlkGyypA=; fh=LzwPoswEbeVNtQPK9MRv3ZmIAvG55vxBfIU+s/tRfbE=; b=N/R2JbrATbkjG2eyCQ96FCYUjs84BMkAQgoSt35kIpyOA7f7PQXIpPLtrbvmKtvx4u HXhrG/GwrkCYlEfDqPTiA4Aw5zR7+IhtHH9L52PF49TXGYRcMx3EdsRPDaEcO4338fFb ImZ/q6+1q5loWjG5svLECYFH8iNyzrrsoyBlbLVEgv1+t+TwwOeLi7amMC7OidtNydjS MXsyYge5d5wTSGPO0wUw6GN5yokRa/2zWpvi0ArGSYaPzfc9U2XOvwl9GtJYiyZgpni3 J/IAQ12yaSx1Hoa9LASke6/fC7Sj2GUzmVBsOfzDWymk1ffJuhBz1K+hC8h9VDkS1cfw msfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id cm23-20020a056a020a1700b0056c55eb251csi1140774pgb.123.2023.11.01.19.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 19:09:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 42CAD801CCC4; Wed, 1 Nov 2023 19:09:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348214AbjKBCJS (ORCPT + 99 others); Wed, 1 Nov 2023 22:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232963AbjKBCJR (ORCPT ); Wed, 1 Nov 2023 22:09:17 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67C81E4; Wed, 1 Nov 2023 19:09:14 -0700 (PDT) Received: from dggpemm500011.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SLRz60VLBzPnZs; Thu, 2 Nov 2023 10:05:06 +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; Thu, 2 Nov 2023 10:09:11 +0800 From: Ren Mingshuai To: CC: , , , , , , , , , Subject: Re: [PATCH] tty: hso: Fix potential null pointer dereference. Date: Thu, 2 Nov 2023 10:09:08 +0800 Message-ID: <20231102020908.692325-1-renmingshuai@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <2023110139-spearmint-throttle-ed90@gregkh> References: <2023110139-spearmint-throttle-ed90@gregkh> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 01 Nov 2023 19:09:31 -0700 (PDT) >> 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. > >If it can not happen, there is no need to check it. So unless you can >prove that this ever could happen, this change isn't needed, right? > >thanks, > >greg k-h Thanks for reply. I agree with you. The reason for checking old there is that it is checked at the beginning in hso_serial_set_termios(). It is better to check it both or not, right? Delete it to avoid smatch complaints. drivers/net/usb/hso.c:1399 hso_serial_set_termios() error: we previously assumed 'old' could be null (see line 1389). diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 4ad829ab54d3..383ff8b04473 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -1386,10 +1386,9 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct hso_serial *serial = tty->driver_data; unsigned long flags; - if (old) - hso_dbg(0x16, "Termios called with: cflags new[%u] - old[%u]\n", - (unsigned int)tty->termios.c_cflag, - (unsigned int)old->c_cflag); + hso_dbg(0x16, "Termios called with: cflags new[%u] - old[%u]\n", + (unsigned int)tty->termios.c_cflag, + (unsigned int)old->c_cflag); /* the actual setup */ spin_lock_irqsave(&serial->serial_lock, flags);