Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5500673imu; Tue, 29 Jan 2019 21:39:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7i6V0xsP3jBn5n1gpTbTSWIoOTNWK4wq4PXh5sDurEPVZriG/HGOJRgWkRPBWFqF6UohQO X-Received: by 2002:a63:2315:: with SMTP id j21mr26651187pgj.297.1548826794881; Tue, 29 Jan 2019 21:39:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548826794; cv=none; d=google.com; s=arc-20160816; b=LJRRKG50lqxQNyV7kTXi2pA7UhvF1AkpXZrnpoTS5sOL5KGhjkeLR+qHLWeV0xBCa0 Z9IhGj0HdObNkw38AADgOceuyTF+pwh0ndWxML9jMIXX34zeH7WSLO9yZXY+0zLGvvMJ H2qxeqcVY7j3ERPTieU+qtq7JpsrWc1QcnOoidftj5o6M5OTIbfATWIDgiIX4nGplyXW H7zNvjRnJG1BNp/AvkhBI4I5TsXJZS6uPbz/X+xttCO72rW38cc61R1kPo5P1aBz4fpZ f5ltXvVxgCPTY+i9TiwDw4J9ZnbX52fUbiu5CmQ1YBSlok2d86QwnVM6+RFaBzTg/4jC oDcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=LdshRunszHp9eukYYa4D9KTgZEYpQJHlXxI/VoNDqWA=; b=dSTsLHWIRal5eEdaJBVNMzC6kzqp1o5iUcZuJ4eEX/g3WQUpKvEC1V0qfQB6C2NbmP dBfV5DBY8qfK7JYsVBFlO5w7D5XhQ1UgwMopLf1CTWzz6FgYBkiC7HCLOig3hRGCydAN D6OVM7201Ks86PftnM6Jtr0vIjAPVIS6Nl1xWOhi8YLJXIWlNblbvGcYK0pzA4hrAG9a WteG5/CC2eGBHIcMqkZ56ikRhK55y6tJT6/DlVsCGC51Ry9tlxQ/WhdZZ6pspZDZw3N/ A2gCAK+ZvtebMTfLawBOQs2aXlaaA0o1SdH+7h7xh7U27QeKW8sHJHPLPUUsXEbbNlTA Swog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pANATjUt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12si627857plc.0.2019.01.29.21.39.40; Tue, 29 Jan 2019 21:39:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pANATjUt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727684AbfA3Fjd (ORCPT + 99 others); Wed, 30 Jan 2019 00:39:33 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37918 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbfA3Fjc (ORCPT ); Wed, 30 Jan 2019 00:39:32 -0500 Received: by mail-pf1-f195.google.com with SMTP id q1so10889959pfi.5; Tue, 29 Jan 2019 21:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=LdshRunszHp9eukYYa4D9KTgZEYpQJHlXxI/VoNDqWA=; b=pANATjUtIsOlIKh9xJTwdx864Jnm3O2x0hlt4dALksiCn4fi3ds3RPlryM30bCGK7f GWZ22xs2F3EasH3jAuD+PKJyyQDhgIwimo5eucrU4pwV3tr3XU89RAkQ2+3IYhokWKJi jlTEKZXleJqXDhDHJSFFzJforVai+Dp9I0r5hA1ftZVZDpOyZdqcntKI1YAkk1Xgg6qZ uOkGOMdVzmVLc9kPVH9hZ3mTkPEACdDtczALCgYrhxukjsXHNUHXNPVqw9iWd0veYlB+ WWNzyLptqjEx3lWhOAr7E4GqgPoYFONyjNdbzBj77pdg9nrNzcadvrvRDxgVuVRR3PtT kkIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=LdshRunszHp9eukYYa4D9KTgZEYpQJHlXxI/VoNDqWA=; b=Fe8lTTpsQa6umkrKc1skBPZz6Dg0qvxwkrOLRVgmPCv/5LTMZxWAf0k5sTlCddNVyg XvZUTytC/wr57npzJzV79czSFJDoz9KqZXZo0JJXu1V/R1K/0DHwpD3pRzaM8gp3eq8N LXvw7z30mYx8ST4Ar53Bt2SkZYUW76vha0auz6jL/wRHVgHSAx6CsLAzgyzSXHOQ9xER +znm/Dcx4iFcxIKThaSsYXwRuyy4FQERe73cGejOTIhTESJSRkcb1rsQgIVvUh4NeMHr 6umBxvFh/vlb0o/wiy7cMx4U09BSaxpjOfiAeTOBkyjqAQYLa3wvCw3SsNjaHZhUj3+r bJ1Q== X-Gm-Message-State: AJcUukeX3iY8hVNKwbjXp3xTrGLF4XhGKvrizCtJUBjn5TUvtQe4FT/g pbDeVQRp0c3wI9fj5xACixk= X-Received: by 2002:a63:6346:: with SMTP id x67mr26250988pgb.183.1548826771294; Tue, 29 Jan 2019 21:39:31 -0800 (PST) Received: from myunghoj-Precision-5530 (cpe-76-176-3-80.san.res.rr.com. [76.176.3.80]) by smtp.gmail.com with ESMTPSA id v89sm1134164pfk.12.2019.01.29.21.39.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 21:39:30 -0800 (PST) Date: Tue, 29 Jan 2019 21:39:28 -0800 From: Myungho Jung To: Marcel Holtmann , Johan Hedberg Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] Bluetooth: Add NULL check for tiocmget() and tiocmset() Message-ID: <20190130053925.GA26699@myunghoj-Precision-5530> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tiocmget() and tiocmset() operations are optional and some tty drivers like pty miss the operations. We need NULL check to prevent from dereference. Signed-off-by: Myungho Jung --- drivers/bluetooth/hci_ath.c | 6 ++++++ drivers/bluetooth/hci_ldisc.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c index d568fbd94d6c..fb9f6323a911 100644 --- a/drivers/bluetooth/hci_ath.c +++ b/drivers/bluetooth/hci_ath.c @@ -185,8 +185,14 @@ static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) static int ath_setup(struct hci_uart *hu) { + struct tty_struct *tty = hu->tty; + BT_DBG("hu %p", hu); + /* tty driver should support operations to set RTS */ + if (!tty->driver->ops->tiocmget || !tty->driver->ops->tiocmset) + return -EOPNOTSUPP; + hu->hdev->set_bdaddr = ath_set_bdaddr; return 0; diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index fbf7b4df23ab..cb31c2d8d826 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -314,6 +314,10 @@ void hci_uart_set_flow_control(struct hci_uart *hu, bool enable) return; } + /* tiocmget() and tiocmset() operations are optional */ + if (!tty->driver->ops->tiocmget || !tty->driver->ops->tiocmset) + return; + if (enable) { /* Disable hardware flow control */ ktermios = tty->termios; -- 2.17.1