• Rajendra Nayak's avatar
    clk: fix parent validation in __clk_set_parent() · 863b1327
    Rajendra Nayak authored
    The below commit introduced a bug in __clk_set_parent()
    which could cause it to *skip* the parent validation
    which makes sure the parent passed to the api is a valid
    one.
    
        commit 7975059d
        Author: Rajendra Nayak <rnayak@ti.com>
        Date:   Wed Jun 6 14:41:31 2012 +0530
    
            clk: Allow late cache allocation for clk->parents
    
    This was identified by the following compiler warning..
    
        drivers/clk/clk.c: In function '__clk_set_parent':
        drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
    
    .. as reported by Marc Kleine-Budde.
    
    There were various options discussed on how to fix this, one
    being initing 'i' to clk->num_parents, but the below approach
    was found to be more appropriate as it also makes the 'parent
    validation' code simpler to read.
    Reported-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: default avatarRajendra Nayak <rnayak@ti.com>
    Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
    Cc: stable@kernel.org
    863b1327
clk.c 37.7 KB