| 1 |
/* Reduced from -Wanalyzer-exposure-through-uninit-copy false positives |
| 2 |
seen in Linux kernel in drivers/net/ethernet/intel/ice/ice_ptp.c */ |
| 3 |
|
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-fanalyzer" } */ |
| 6 |
/* { dg-require-effective-target analyzer } */ |
| 7 |
|
| 8 |
extern unsigned long |
| 9 |
copy_from_user(void* to, const void* from, unsigned long n); |
| 10 |
|
| 11 |
extern unsigned long |
| 12 |
copy_to_user(void* to, const void* from, unsigned long n); |
| 13 |
|
| 14 |
struct ifreq |
| 15 |
{ |
| 16 |
union |
| 17 |
{ |
| 18 |
void* ifru_data; |
| 19 |
} ifr_ifru; |
| 20 |
}; |
| 21 |
|
| 22 |
struct hwtstamp_config |
| 23 |
{ |
| 24 |
int flags; |
| 25 |
int tx_type; |
| 26 |
int rx_filter; |
| 27 |
}; |
| 28 |
|
| 29 |
struct ice_ptp |
| 30 |
{ |
| 31 |
long placeholder; |
| 32 |
struct hwtstamp_config tstamp_config; |
| 33 |
}; |
| 34 |
|
| 35 |
struct ice_pf |
| 36 |
{ |
| 37 |
struct ice_ptp ptp; |
| 38 |
}; |
| 39 |
int |
| 40 |
ice_ptp_set_ts_config(struct ice_pf* pf, struct ifreq* ifr) |
| 41 |
{ |
| 42 |
struct hwtstamp_config config; |
| 43 |
int err; |
| 44 |
if (copy_from_user(&config, ifr->ifr_ifru.ifru_data, sizeof(config))) |
| 45 |
return -14; |
| 46 |
pf->ptp.tstamp_config.tx_type = 0; |
| 47 |
pf->ptp.tstamp_config.rx_filter = 0; |
| 48 |
config = pf->ptp.tstamp_config; |
| 49 |
if (copy_to_user(ifr->ifr_ifru.ifru_data, &config, sizeof(config))) /* { dg-bogus "-Wanalyzer-exposure-through-uninit-copy" "PR analyzer/112969" } */ |
| 50 |
return -14; |
| 51 |
return 0; |
| 52 |
} |