From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Rosin Date: Thu, 18 Feb 2016 23:13:43 +0000 Subject: Re: [lm-sensors] [PATCH] hwmon: (ads1015) Handle negative conversion values correctly Message-Id: <56C65027.5010403@lysator.liu.se> List-Id: References: <1455800872-24431-1-git-send-email-peda@lysator.liu.se> In-Reply-To: <1455800872-24431-1-git-send-email-peda@lysator.liu.se> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dirk Eibach Cc: Peter Rosin , Jean Delvare , Guenter Roeck , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org Hi! Sorry for the noise, but... On 2016-02-18 14:07, Peter Rosin wrote: > From: Peter Rosin > > Make the divisor signed as DIV_ROUND_CLOSEST is undefined for negative > dividends when the divisor is unsigned. > > Signed-off-by: Peter Rosin ...I forgot to add this to the commit message Cc: stable@vger.kernel.org I also didn't explicitly mention any example platform where this bug causes real problems; it was triggered on ARM (atmel sama5d). Cheers, Peter > --- > drivers/hwmon/ads1015.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c > index f155b8380481..2b3105c8aed3 100644 > --- a/drivers/hwmon/ads1015.c > +++ b/drivers/hwmon/ads1015.c > @@ -126,7 +126,7 @@ static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel, > struct ads1015_data *data = i2c_get_clientdata(client); > unsigned int pga = data->channel_data[channel].pga; > int fullscale = fullscale_table[pga]; > - const unsigned mask = data->id = ads1115 ? 0x7fff : 0x7ff0; > + const int mask = data->id = ads1115 ? 0x7fff : 0x7ff0; > > return DIV_ROUND_CLOSEST(reg * fullscale, mask); > } > _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947636AbcBRXNs (ORCPT ); Thu, 18 Feb 2016 18:13:48 -0500 Received: from mail.lysator.liu.se ([130.236.254.3]:53339 "EHLO mail.lysator.liu.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946276AbcBRXNq (ORCPT ); Thu, 18 Feb 2016 18:13:46 -0500 Message-ID: <56C65027.5010403@lysator.liu.se> Date: Fri, 19 Feb 2016 00:13:43 +0100 From: Peter Rosin User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Dirk Eibach CC: Peter Rosin , Jean Delvare , Guenter Roeck , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hwmon: (ads1015) Handle negative conversion values correctly References: <1455800872-24431-1-git-send-email-peda@lysator.liu.se> In-Reply-To: <1455800872-24431-1-git-send-email-peda@lysator.liu.se> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! Sorry for the noise, but... On 2016-02-18 14:07, Peter Rosin wrote: > From: Peter Rosin > > Make the divisor signed as DIV_ROUND_CLOSEST is undefined for negative > dividends when the divisor is unsigned. > > Signed-off-by: Peter Rosin ...I forgot to add this to the commit message Cc: stable@vger.kernel.org I also didn't explicitly mention any example platform where this bug causes real problems; it was triggered on ARM (atmel sama5d). Cheers, Peter > --- > drivers/hwmon/ads1015.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c > index f155b8380481..2b3105c8aed3 100644 > --- a/drivers/hwmon/ads1015.c > +++ b/drivers/hwmon/ads1015.c > @@ -126,7 +126,7 @@ static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel, > struct ads1015_data *data = i2c_get_clientdata(client); > unsigned int pga = data->channel_data[channel].pga; > int fullscale = fullscale_table[pga]; > - const unsigned mask = data->id == ads1115 ? 0x7fff : 0x7ff0; > + const int mask = data->id == ads1115 ? 0x7fff : 0x7ff0; > > return DIV_ROUND_CLOSEST(reg * fullscale, mask); > } >