lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <AS4PR04MB969235CFCC9D2D74A5C17322E7C92@AS4PR04MB9692.eurprd04.prod.outlook.com>
Date: Mon, 3 Mar 2025 09:24:52 +0000
From: Neeraj Sanjay Kale <neeraj.sanjaykale@....com>
To: Luiz Augusto von Dentz <luiz.dentz@...il.com>
CC: "marcel@...tmann.org" <marcel@...tmann.org>, "robh@...nel.org"
	<robh@...nel.org>, "krzk+dt@...nel.org" <krzk+dt@...nel.org>,
	"conor+dt@...nel.org" <conor+dt@...nel.org>,
	"linux-bluetooth@...r.kernel.org" <linux-bluetooth@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>, Amitkumar Karwar
	<amitkumar.karwar@....com>, Sherry Sun <sherry.sun@....com>, Luke Wang
	<ziniu.wang_1@....com>, "johan.korsnes@...arkable.no"
	<johan.korsnes@...arkable.no>, "kristian.krohn@...arkable.no"
	<kristian.krohn@...arkable.no>, Manjeet Gupta <manjeet.gupta@....com>
Subject: Re: [PATCH v6 2/2] Bluetooth: btnxpuart: Add support to set BD
 address

Hi Luiz,

Thank you for reviewing the patch.

> > @@ -1197,6 +1209,38 @@ static int nxp_set_ind_reset(struct hci_dev
> *hdev, void *data)
> >         return hci_recv_frame(hdev, skb);  }
> >
> > +static int nxp_set_bdaddr(struct hci_dev *hdev, const bdaddr_t
> > +*bdaddr) {
> > +       union nxp_set_bd_addr_payload pcmd;
> > +       struct sk_buff *skb;
> > +       int err;
> > +
> > +       pcmd.data.param_id = 0xfe;
> > +       pcmd.data.param_len = 6;
> > +       memcpy(pcmd.data.param, bdaddr, 6);
> > +
> > +       /* BD address can be assigned only after first reset command. */
> > +       skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL,
> HCI_INIT_TIMEOUT);
> > +       if (IS_ERR(skb)) {
> > +               err = PTR_ERR(skb);
> > +               bt_dev_err(hdev, "Reset before setting local-bd-addr failed (%ld)",
> > +                          PTR_ERR(skb));
> > +               return err;
> > +       }
> > +       kfree_skb(skb);
> 
> If you don't care about the response, just the status, it is probably better to
> use __hci_cmd_sync_status, also since the hdev->set_bdaddr comes after
> hdev->setup doesn't the later do perform a reset anyway?
> If you end up with 2 resets in a row it problems means you don't need to
> reset again.

Hdev->set_bdaddr comes after hdev->setup, but comes before the first HCI RESET.

With this patch, if Device Tree has a local-bd-addr property, hdev->set_bdaddr will send HCI RESET, followed by 3f22 command, and then HCI RESET again during initialization, along with READ LOCAL FEATURES, READ LOCAL VERSION and READ BD ADDR. 

Without local-bd-addr DT property, hdev->set_bdaddr will be skipped and only one HCI RESET will be sent.
> 
> > +
> > +       skb = __hci_cmd_sync(hdev, HCI_NXP_SET_BD_ADDR, sizeof(pcmd),
> > +                            pcmd.buf, HCI_CMD_TIMEOUT);
> 
> Ditto.
> 
> > +       if (IS_ERR(skb)) {
> > +               err = PTR_ERR(skb);
> > +               bt_dev_err(hdev, "Changing device address failed (%d)", err);
> > +               return err;
> > +       }
> > +       kfree_skb(skb);
> > +
> > +       return 0;
> > +}
> > +
> >  /* NXP protocol */

Thanks,
Neeraj

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ