hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/nfc/st-nci/se.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Secure Element driver for STMicroelectronics NFC NCI chip
34 *
45 * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
176 */
187
198 #include <linux/module.h>
....@@ -338,12 +327,11 @@
338327 * AID 81 5 to 16
339328 * PARAMETERS 82 0 to 255
340329 */
341
- if (skb->len < NFC_MIN_AID_LENGTH + 2 &&
330
+ if (skb->len < NFC_MIN_AID_LENGTH + 2 ||
342331 skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG)
343332 return -EPROTO;
344333
345
- transaction = (struct nfc_evt_transaction *)devm_kzalloc(dev,
346
- skb->len - 2, GFP_KERNEL);
334
+ transaction = devm_kzalloc(dev, skb->len - 2, GFP_KERNEL);
347335 if (!transaction)
348336 return -ENOMEM;
349337
....@@ -352,8 +340,10 @@
352340
353341 /* Check next byte is PARAMETERS tag (82) */
354342 if (skb->data[transaction->aid_len + 2] !=
355
- NFC_EVT_TRANSACTION_PARAMS_TAG)
343
+ NFC_EVT_TRANSACTION_PARAMS_TAG) {
344
+ devm_kfree(dev, transaction);
356345 return -EPROTO;
346
+ }
357347
358348 transaction->params_len = skb->data[transaction->aid_len + 3];
359349 memcpy(transaction->params, skb->data +