]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nfc: Remove checks for nla_data returning NULL
authorSimon Horman <horms@kernel.org>
Tue, 17 Jun 2025 08:45:39 +0000 (09:45 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 18 Jun 2025 21:17:32 +0000 (14:17 -0700)
The implementation of nla_data is as follows:

static inline void *nla_data(const struct nlattr *nla)
{
return (char *) nla + NLA_HDRLEN;
}

Excluding the case where nla is exactly -NLA_HDRLEN, it will not return
NULL. And it seems misleading to assume that it can, other than in this
corner case. So drop checks for this condition.

Flagged by Smatch.

Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250617-nfc-null-data-v1-1-c7525ead2e95@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/nfc/netlink.c

index 6a40b8d0350d944b05a36c2581ac7382b1c6cb7d..a18e2c503da61a81afe5595529437f4b1f2fbf90 100644 (file)
@@ -1192,7 +1192,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
                        continue;
 
                uri = nla_data(sdp_attrs[NFC_SDP_ATTR_URI]);
-               if (uri == NULL || *uri == 0)
+               if (*uri == 0)
                        continue;
 
                tid = local->sdreq_next_tid++;
@@ -1540,10 +1540,6 @@ static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
        }
 
        apdu = nla_data(info->attrs[NFC_ATTR_SE_APDU]);
-       if (!apdu) {
-               rc = -EINVAL;
-               goto put_dev;
-       }
 
        ctx = kzalloc(sizeof(struct se_io_ctx), GFP_KERNEL);
        if (!ctx) {