diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-07-24 23:47:33 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-07-25 10:21:20 +0200 |
commit | b9c28286d8f1822a10f702fcefe0b8a1db4e6917 (patch) | |
tree | 4220028d575e0cac82c578cd243e31947e8df0c3 /net/nfc/nci | |
parent | nfc: constify payload argument in nci_send_cmd() (diff) | |
download | linux-b9c28286d8f1822a10f702fcefe0b8a1db4e6917.tar.xz linux-b9c28286d8f1822a10f702fcefe0b8a1db4e6917.zip |
nfc: constify nci_ops
The struct nci_ops is modified by NFC core in only one case:
nci_allocate_device() receives too many proprietary commands (prop_ops)
to configure. This is a build time known constrain, so a graceful
handling of such case is not necessary.
Instead, fail the nci_allocate_device() and add BUILD_BUG_ON() to places
which set these.
This allows to constify the struct nci_ops (consisting of function
pointers) for correctness and safety.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/nfc/nci')
-rw-r--r-- | net/nfc/nci/core.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 09967b836361..a7d26f2791b0 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -1129,7 +1129,7 @@ static struct nfc_ops nci_nfc_ops = { * @tx_headroom: Reserved space at beginning of skb * @tx_tailroom: Reserved space at end of skb */ -struct nci_dev *nci_allocate_device(struct nci_ops *ops, +struct nci_dev *nci_allocate_device(const struct nci_ops *ops, __u32 supported_protocols, int tx_headroom, int tx_tailroom) { @@ -1152,8 +1152,7 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops, if (ops->n_prop_ops > NCI_MAX_PROPRIETARY_CMD) { pr_err("Too many proprietary commands: %zd\n", ops->n_prop_ops); - ops->prop_ops = NULL; - ops->n_prop_ops = 0; + goto free_nci; } ndev->tx_headroom = tx_headroom; |