Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3149770imu; Sun, 27 Jan 2019 22:59:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Cc7D7oqzBEmMV6Hy6EdA5Fq6Obr/qy1prkpM2EdOOz+aZRWjx5N7Ms3pGi5usuiTtB0WC X-Received: by 2002:a63:1a4b:: with SMTP id a11mr18873865pgm.254.1548658780359; Sun, 27 Jan 2019 22:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548658780; cv=none; d=google.com; s=arc-20160816; b=NCGu+TrklqOmDVjhXqMbfv7bJsjZXJfcQbGx94gF1JwM4XdNIEIcTOY2i/WeHaQbzr dF+lAOt/+lTwvqMxQ7U9BQnfop4dXeQ7peG9erltRdoo6e+FQRrfu4dxl3Vc9YUvbYFK pZz16fE+IGuvpYsbxb3rjikVKeet6yBTNVOQhU+IqAgi2wR1vIuRpjgUhXkISc5b2bry gVGWiiKE9/3Ihv0RBj8sUhytzKcgEoqBtFedhr3bU1GQIkYxosoGXBBhJvLl+eS4X2at pP+UeKxMBOxuaQVcjtyNtzURYQs+hQuffPvBJja9WS7tPA85OH9223ICVoxtIqTROclU ABKQ== 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=PPMteN8p8+yuCViHNNM49LqdtRO2VGHUxenNraKRdGo=; b=HKsp8roJrD1jixLh6GIGzLjcNgbsI4EG4VJjMyCNYX7xJB9RaurVX9Enx+eDhUZ8Km iCT93VF+WO9zGzDFSiCnR/uTLOfgPerl1K7yP6SM06ZHu8VSCw8Wy0xUA4g4BMYWk9ih kC6KwrHS/SKvlKWkNKr3nmy6NLxJW9zciIbr6YwjIhG8R+m0/qEg7EhW/H3zqyNc5P7I mLqUag/hCVJc6lc4RJk6PDHy5ki53sk9A6f2QGZiRYEs1TkZFgOmYGXw6qv+XiwO35DB wD5FFoAr5kUmxmq9exzjCAijmlqHuZPxL+yOlIOriC6tm3QYEh4PAXvjquUE+lK3mUhr 7eKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L9zGyJh9; 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 e1si11737203pln.55.2019.01.27.22.59.25; Sun, 27 Jan 2019 22:59:40 -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=L9zGyJh9; 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 S1726754AbfA1G7Q (ORCPT + 99 others); Mon, 28 Jan 2019 01:59:16 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35784 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbfA1G7Q (ORCPT ); Mon, 28 Jan 2019 01:59:16 -0500 Received: by mail-pf1-f195.google.com with SMTP id z9so7591529pfi.2; Sun, 27 Jan 2019 22:59:16 -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=PPMteN8p8+yuCViHNNM49LqdtRO2VGHUxenNraKRdGo=; b=L9zGyJh9Y/e3HFRUllXUMPl1KLB83+oaZLPctuxJbbLP62ZUBeoUcdCw00vZDzSt7o IUBxOw+uP/qUcBoyFNsg25949GMQZP9Qe3oSVnWP3NUnY9fzhOlpHdNNQG+Csh5ygskw 455UK8pddgzYHwPoo+rsf961yQdcCa3jTlvHDwLEj6Jzt/M1PwpTP6R9LBEO29pSss78 2Ke+yKTseBHwA/zrwiHTsCmILjahbTnoMQq7CbueS9+fvvv/T6Z9zaetvqnz711UFW6d ZwHXeq1IENod6Sf1uB5nAY4gwTLUfw2wqwju5xp2AmOG1DTzNvJ/aGObRjFi/cfGilHP zzmA== 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=PPMteN8p8+yuCViHNNM49LqdtRO2VGHUxenNraKRdGo=; b=aRmJt8/DwPs2RE/BgPXt8sXt4JnU+C+8nJeCzpG5AljRgoAJwwCu5+QGKsR+ChI7EW 8LpdOfUTxA4/b+r7s/tTkUKD6A7Vx3yBT3bSyvltTrUv09jflw8E6PYOHI3lw0alTS1X mQ2Zz6cByV755ohTsYnrJ0oS3T91V8WglDBYbcB5wvoXsTST+xk4R5QiQmmUYqbgeZK4 1lIAC503IoBRghH3Mnt2eng8jnrqZFx64MPSoOkT6IyhE58vRlxqWOgwv4Q/J3MS+MRF jeRyVH4YNxtpiesV76YM/i45eGf1hGsbWoib8CR68TKGKtPjv+me7XZWSTKvWk2nwP+A jzGw== X-Gm-Message-State: AJcUukenurRycqMJtjyKJLYKRMKzOzocivOz3zSUS92KXdtWLkMXY00v iF0AxXD2TTOItttPoWPGo/M= X-Received: by 2002:a63:165e:: with SMTP id 30mr18830259pgw.103.1548658755709; Sun, 27 Jan 2019 22:59:15 -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 r66sm50393263pfk.157.2019.01.27.22.59.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 Jan 2019 22:59:15 -0800 (PST) Date: Sun, 27 Jan 2019 22:59:13 -0800 From: Myungho Jung To: Marcel Holtmann , Johan Hedberg Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: Add NULL check for tiocmget() and tiocmset() Message-ID: <20190128065910.GA14959@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 before referencing them. Reported-by: syzbot+a950165cbb86bdd023a4@syzkaller.appspotmail.com Signed-off-by: Myungho Jung --- drivers/bluetooth/hci_ath.c | 13 ++++++++----- drivers/bluetooth/hci_ldisc.c | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c index d568fbd94d6c..076700a1e9a8 100644 --- a/drivers/bluetooth/hci_ath.c +++ b/drivers/bluetooth/hci_ath.c @@ -94,11 +94,14 @@ static void ath_hci_uart_work(struct work_struct *work) hu = ath->hu; tty = hu->tty; - /* verify and wake up controller */ - if (ath->cur_sleep) { - status = ath_wakeup_ar3k(tty); - if (!(status & TIOCM_CTS)) - return; + /* tiocmget() and tiocmset() operations are optional */ + if (tty->driver->ops->tiocmget && tty->driver->ops->tiocmset) { + /* verify and wake up controller */ + if (ath->cur_sleep) { + status = ath_wakeup_ar3k(tty); + if (!(status & TIOCM_CTS)) + return; + } } /* Ready to send Data */ diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index fbf7b4df23ab..9f88a8563cf6 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -314,6 +314,11 @@ 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