Bug 44031 - e500_tlb.c: 2 * bad call to memset
Summary: e500_tlb.c: 2 * bad call to memset
Status: RESOLVED CODE_FIX
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: PPC-32 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Alan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-01 11:53 UTC by David Binderman
Modified: 2012-09-05 20:39 UTC (History)
2 users (show)

See Also:
Kernel Version: 3.5-rc5
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description David Binderman 2012-07-01 11:53:44 UTC
I just ran the static analyser "cppcheck" over the source
code of the Linux Kernel.

It said

[linux-3.5-rc5/arch/powerpc/kvm/e500_tlb.c:325]: (warning) memset() called to fill 0 bytes of 'vcpu_e500'
[linux-3.5-rc5/arch/powerpc/kvm/e500_tlb.c:328]: (warning) memset() called to fill 0 bytes of 'vcpu_e500'

The source code is

    if (vcpu_e500->g2h_tlb1_map)
        memset(vcpu_e500->g2h_tlb1_map,
               sizeof(u64) * vcpu_e500->gtlb_params[1].entries, 0);
    if (vcpu_e500->h2g_tlb1_rmap)
        memset(vcpu_e500->h2g_tlb1_rmap,
               sizeof(unsigned int) * host_tlb_params[1].entries, 0);

Suggest swap parameters 2 & 3 of the calls to memset.
Comment 1 Alan 2012-07-02 12:52:51 UTC
Patch queued
Comment 2 Florian Mickler 2012-09-05 20:39:48 UTC
A patch referencing this bug report has been merged in Linux v3.6-rc4:

commit e8143ccb6b501f78bb95d9c5ee100d18423008cf
Author: Alan Cox <alan@linux.intel.com>
Date:   Tue Aug 14 12:10:09 2012 +0000

    ppc: e500_tlb memset clears nothing

Note You need to log in before you can comment on or make changes to this bug.