Re: [PATCH] power: supply: sbs-message: double left shift bug in sbsm_select()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, Nov 07, 2017 at 03:43:22PM +0300, Dan Carpenter wrote:
> The original code does this: "1 << (1 << 11)" which is undefined in C.
> 
> Fixes: dbc4deda03fe ("power: Adds support for Smart Battery System Manager")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> From static analysis.  Not tested.
> 
> diff --git a/drivers/power/supply/sbs-manager.c b/drivers/power/supply/sbs-manager.c
> index ccb4217b9638..cb6e8f66c7a2 100644
> --- a/drivers/power/supply/sbs-manager.c
> +++ b/drivers/power/supply/sbs-manager.c
> @@ -183,7 +183,7 @@ static int sbsm_select(struct i2c_mux_core *muxc, u32 chan)
>  		return ret;
>  
>  	/* chan goes from 1 ... 4 */
> -	reg = 1 << BIT(SBSM_SMB_BAT_OFFSET + chan);
> +	reg = BIT(SBSM_SMB_BAT_OFFSET + chan);
>  	ret = sbsm_write_word(data->client, SBSM_CMD_BATSYSSTATE, reg);
>  	if (ret)
>  		dev_err(dev, "Failed to select channel %i\n", chan);

Reviewed-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxxxx>

sbs-manager has been added to linux-next through the i2c tree due to
dependencies, so this one also needs to go through i2c.

-- Sebastian

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux