diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2014-11-30 12:03:49 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-12-02 19:15:02 -0500 |
commit | eb94ec7a6516cd1dc52c0f63d7c3a274e6337416 (patch) | |
tree | dea11e9e5f49de50fbb38e982b3fad742b90d7d4 /drivers/usb | |
parent | b19e5f04cd628c012c26a025cf93da5233df134d (diff) |
wusb: replace memset by memzero_explicit
Memset on a local variable may be removed when it is called just before the
variable goes out of scope. Using memzero_explicit defeats this
optimization. A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
identifier x;
type T;
@@
{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
(x,
-0,
...)
... when != x
when strict
}
// </smpl>
This change was suggested by Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/wusbcore/dev-sysfs.c | 2 | ||||
-rw-r--r-- | drivers/usb/wusbcore/security.c | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/usb/wusbcore/dev-sysfs.c b/drivers/usb/wusbcore/dev-sysfs.c index 101834576236..415b14002a61 100644 --- a/drivers/usb/wusbcore/dev-sysfs.c +++ b/drivers/usb/wusbcore/dev-sysfs.c | |||
@@ -101,7 +101,7 @@ static ssize_t wusb_ck_store(struct device *dev, | |||
101 | if (wusbhc == NULL) | 101 | if (wusbhc == NULL) |
102 | return -ENODEV; | 102 | return -ENODEV; |
103 | result = wusb_dev_4way_handshake(wusbhc, usb_dev->wusb_dev, &ck); | 103 | result = wusb_dev_4way_handshake(wusbhc, usb_dev->wusb_dev, &ck); |
104 | memset(&ck, 0, sizeof(ck)); | 104 | memzero_explicit(&ck, sizeof(ck)); |
105 | wusbhc_put(wusbhc); | 105 | wusbhc_put(wusbhc); |
106 | return result < 0 ? result : size; | 106 | return result < 0 ? result : size; |
107 | } | 107 | } |
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c index cc74d669c802..b66faaf3e842 100644 --- a/drivers/usb/wusbcore/security.c +++ b/drivers/usb/wusbcore/security.c | |||
@@ -522,10 +522,10 @@ error_hs3: | |||
522 | error_hs2: | 522 | error_hs2: |
523 | error_hs1: | 523 | error_hs1: |
524 | memset(hs, 0, 3*sizeof(hs[0])); | 524 | memset(hs, 0, 3*sizeof(hs[0])); |
525 | memset(&keydvt_out, 0, sizeof(keydvt_out)); | 525 | memzero_explicit(&keydvt_out, sizeof(keydvt_out)); |
526 | memset(&keydvt_in, 0, sizeof(keydvt_in)); | 526 | memzero_explicit(&keydvt_in, sizeof(keydvt_in)); |
527 | memset(&ccm_n, 0, sizeof(ccm_n)); | 527 | memzero_explicit(&ccm_n, sizeof(ccm_n)); |
528 | memset(mic, 0, sizeof(mic)); | 528 | memzero_explicit(mic, sizeof(mic)); |
529 | if (result < 0) | 529 | if (result < 0) |
530 | wusb_dev_set_encryption(usb_dev, 0); | 530 | wusb_dev_set_encryption(usb_dev, 0); |
531 | error_dev_set_encryption: | 531 | error_dev_set_encryption: |