* [PATCH] nfc: pn533: fix memcpy overflow warning
@ 2026-06-08 5:00 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-06-08 5:00 UTC (permalink / raw)
To: oe-linux-nfc; +Cc: David Heidelberg, open list
error: call to ‘__read_overflow2_field’ declared with attribute warning:
detected read beyond size of field (2nd parameter); maybe use
struct_group()? [-Werror=attribute-warning]
As suggested, add a struct_group and memcpy that.
Also replace 9 with sizeof for clarify.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/nfc/pn533/pn533.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index d7bdbc82e2ba..4e721a8dfd8b 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -740,8 +740,10 @@ static int pn533_target_found_type_a(struct nfc_target *nfc_tgt, u8 *tgt_data,
struct pn533_target_felica {
u8 pol_res;
- u8 opcode;
- u8 nfcid2[NFC_NFCID2_MAXSIZE];
+ struct_group(sensf_res,
+ u8 opcode;
+ u8 nfcid2[NFC_NFCID2_MAXSIZE];
+ );
u8 pad[8];
/* optional */
u8 syst_code[];
@@ -778,8 +780,8 @@ static int pn533_target_found_felica(struct nfc_target *nfc_tgt, u8 *tgt_data,
else
nfc_tgt->supported_protocols = NFC_PROTO_FELICA_MASK;
- memcpy(nfc_tgt->sensf_res, &tgt_felica->opcode, 9);
- nfc_tgt->sensf_res_len = 9;
+ memcpy(nfc_tgt->sensf_res, &tgt_felica->sensf_res, sizeof(tgt_felica->sensf_res));
+ nfc_tgt->sensf_res_len = sizeof(tgt_felica->sensf_res);
memcpy(nfc_tgt->nfcid2, tgt_felica->nfcid2, NFC_NFCID2_MAXSIZE);
nfc_tgt->nfcid2_len = NFC_NFCID2_MAXSIZE;
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-08 5:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-08 5:00 [PATCH] nfc: pn533: fix memcpy overflow warning Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome