Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcb73338 authored by Andrei Emeltchenko's avatar Andrei Emeltchenko Committed by Gustavo Padovan
Browse files

Bluetooth: Use %pMR in sprintf/seq_printf instead of batostr



Instead of old unsafe batostr function use %pMR print specifier
for printing Bluetooth addresses in sprintf and seq_printf
statements.

Signed-off-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 6ed93dc6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)

	BT_DBG("mtu %d", session->mtu);

	sprintf(session->name, "%s", batostr(&bt_sk(sock->sk)->dst));
	sprintf(session->name, "%pMR", &bt_sk(sock->sk)->dst);

	session->sock  = sock;
	session->state = BT_CONFIG;
+5 −5
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ static ssize_t show_link_address(struct device *dev,
				 struct device_attribute *attr, char *buf)
{
	struct hci_conn *conn = to_hci_conn(dev);
	return sprintf(buf, "%s\n", batostr(&conn->dst));
	return sprintf(buf, "%pMR\n", &conn->dst);
}

static ssize_t show_link_features(struct device *dev,
@@ -224,7 +224,7 @@ static ssize_t show_address(struct device *dev,
			    struct device_attribute *attr, char *buf)
{
	struct hci_dev *hdev = to_hci_dev(dev);
	return sprintf(buf, "%s\n", batostr(&hdev->bdaddr));
	return sprintf(buf, "%pMR\n", &hdev->bdaddr);
}

static ssize_t show_features(struct device *dev,
@@ -406,8 +406,8 @@ static int inquiry_cache_show(struct seq_file *f, void *p)

	list_for_each_entry(e, &cache->all, all) {
		struct inquiry_data *data = &e->data;
		seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
			   batostr(&data->bdaddr),
		seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
			   &data->bdaddr,
			   data->pscan_rep_mode, data->pscan_period_mode,
			   data->pscan_mode, data->dev_class[2],
			   data->dev_class[1], data->dev_class[0],
@@ -440,7 +440,7 @@ static int blacklist_show(struct seq_file *f, void *p)
	hci_dev_lock(hdev);

	list_for_each_entry(b, &hdev->blacklist, list)
		seq_printf(f, "%s\n", batostr(&b->bdaddr));
		seq_printf(f, "%pMR\n", &b->bdaddr);

	hci_dev_unlock(hdev);

+6 −2
Original line number Diff line number Diff line
@@ -932,8 +932,12 @@ static int hidp_setup_hid(struct hidp_session *session,
	hid->country = req->country;

	strncpy(hid->name, req->name, 128);
	strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64);
	strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64);

	snprintf(hid->phys, sizeof(hid->phys), "%pMR",
		 &bt_sk(session->ctrl_sock->sk)->src);

	snprintf(hid->uniq, sizeof(hid->uniq), "%pMR",
		 &bt_sk(session->ctrl_sock->sk)->dst);

	hid->dev.parent = &session->conn->dev;
	hid->ll_driver = &hidp_hid_driver;
+5 −6
Original line number Diff line number Diff line
@@ -5640,9 +5640,8 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
	list_for_each_entry(c, &chan_list, global_l) {
		struct sock *sk = c->sk;

		seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
					batostr(&bt_sk(sk)->src),
					batostr(&bt_sk(sk)->dst),
		seq_printf(f, "%pMR %pMR %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n",
			   &bt_sk(sk)->src, &bt_sk(sk)->dst,
			   c->state, __le16_to_cpu(c->psm),
			   c->scid, c->dcid, c->imtu, c->omtu,
			   c->sec_level, c->mode);
+4 −5
Original line number Diff line number Diff line
@@ -2125,9 +2125,8 @@ static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
		list_for_each_entry(d, &s->dlcs, list) {
			struct sock *sk = s->sock->sk;

			seq_printf(f, "%s %s %ld %d %d %d %d\n",
						batostr(&bt_sk(sk)->src),
						batostr(&bt_sk(sk)->dst),
			seq_printf(f, "%pMR %pMR %ld %d %d %d %d\n",
				   &bt_sk(sk)->src, &bt_sk(sk)->dst,
				   d->state, d->dlci, d->mtu,
				   d->rx_credits, d->tx_credits);
		}
Loading