Bug 80431 - drivers/edac/edac_module.c:31: pointless code ?
Summary: drivers/edac/edac_module.c:31: pointless code ?
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: EDAC (show other bugs)
Hardware: All Linux
: P1 low
Assignee: drivers_edac@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-16 20:37 UTC by David Binderman
Modified: 2014-07-17 12:30 UTC (History)
1 user (show)

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


Attachments

Description David Binderman 2014-07-16 20:37:20 UTC
[linux-3.16-rc5/drivers/edac/edac_module.c:31]: (style) Checking if unsigned variable 'val' is less than zero.

Source code is

    if (val < 0 || val > 4)

but

    unsigned long val;
Comment 1 Andrey Utkin 2014-07-17 12:17:51 UTC
linux-next has it fixed. But it somehow didn't get into linux-stable up to now.

commit 6866b390562b2c948c6f6fc2a5c103f090a02e01
Author: Fabian Frederick <fabf@skynet.be>
Date:   Mon Jun 9 21:20:18 2014 +0200

    EDAC, edac_module.c: Remove unnecessary test on unsigned value
    
    unsigned long value is never < 0.
    
    Cc: Doug Thompson <dougthompson@xmission.com>
    Signed-off-by: Fabian Frederick <fabf@skynet.be>
    Link: http://lkml.kernel.org/r/1402341618-10674-1-git-send-email-fabf@skynet.be
    Signed-off-by: Borislav Petkov <bp@suse.de>

diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c
index a66941f..e6d1691 100644
--- a/drivers/edac/edac_module.c
+++ b/drivers/edac/edac_module.c
@@ -28,7 +28,7 @@ static int edac_set_debug_level(const char *buf, struct kernel_param *kp)
        if (ret)
                return ret;
 
-       if (val < 0 || val > 4)
+       if (val > 4)
                return -EINVAL;
 
        return param_set_int(buf, kp);
Comment 2 Andrey Utkin 2014-07-17 12:30:10 UTC
Notified maintainers: http://marc.info/?l=linux-kernel&m=140559999820015&w=2

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