File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 36
36
#include <linux/memcontrol.h>
37
37
#include <linux/trace_events.h>
38
38
#include <linux/tracepoint.h>
39
+ #include <linux/overflow.h>
39
40
40
41
#include <net/netfilter/nf_bpf_link.h>
41
42
#include <net/netkit.h>
@@ -693,7 +694,7 @@ struct btf_record *btf_record_dup(const struct btf_record *rec)
693
694
694
695
if (IS_ERR_OR_NULL (rec ))
695
696
return NULL ;
696
- size = offsetof( struct btf_record , fields [ rec -> cnt ] );
697
+ size = struct_size ( rec , fields , rec -> cnt );
697
698
new_rec = kmemdup (rec , size , GFP_KERNEL | __GFP_NOWARN );
698
699
if (!new_rec )
699
700
return ERR_PTR (- ENOMEM );
@@ -748,7 +749,7 @@ bool btf_record_equal(const struct btf_record *rec_a, const struct btf_record *r
748
749
return false;
749
750
if (rec_a -> cnt != rec_b -> cnt )
750
751
return false;
751
- size = offsetof( struct btf_record , fields [ rec_a -> cnt ] );
752
+ size = struct_size ( rec_a , fields , rec_a -> cnt );
752
753
/* btf_parse_fields uses kzalloc to allocate a btf_record, so unused
753
754
* members are zeroed out. So memcmp is safe to do without worrying
754
755
* about padding/unused fields.
You can’t perform that action at this time.
0 commit comments