All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Axel Lin <axel.lin@ingics.com>,
	Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 3.10 21/55] hwmon: (lm85) Fix various errors on attribute writes
Date: Wed,  3 Sep 2014 15:05:11 -0700	[thread overview]
Message-ID: <20140903220457.313895831@linuxfoundation.org> (raw)
In-Reply-To: <20140903220453.653576908@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guenter Roeck <linux@roeck-us.net>

commit 3248c3b771ddd9d31695da17ba350eb6e1b80a53 upstream.

Temperature limit register writes did not account for negative numbers.
As a result, writing -127000 resulted in -126000 written into the
temperature limit register. This problem affected temp[1-3]_min,
temp[1-3]_max, temp[1-3]_auto_temp_crit, and temp[1-3]_auto_temp_min.

When writing pwm[1-3]_freq, a long variable was auto-converted into an int
without range check. Wiring values larger than MAXINT resulted in unexpected
register values.

When writing temp[1-3]_auto_temp_max, an unsigned long variable was
auto-converted into an int without range check. Writing values larger than
MAXINT resulted in unexpected register values.

vrm is an u8, so the written value needs to be limited to [0, 255].

Cc: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hwmon/lm85.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -158,7 +158,7 @@ static inline u16 FAN_TO_REG(unsigned lo
 
 /* Temperature is reported in .001 degC increments */
 #define TEMP_TO_REG(val)	\
-		clamp_val(SCALE(val, 1000, 1), -127, 127)
+		DIV_ROUND_CLOSEST(clamp_val((val), -127000, 127000), 1000)
 #define TEMPEXT_FROM_REG(val, ext)	\
 		SCALE(((val) << 4) + (ext), 16, 1000)
 #define TEMP_FROM_REG(val)	((val) * 1000)
@@ -192,7 +192,7 @@ static const int lm85_range_map[] = {
 	13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000
 };
 
-static int RANGE_TO_REG(int range)
+static int RANGE_TO_REG(long range)
 {
 	int i;
 
@@ -214,7 +214,7 @@ static const int adm1027_freq_map[8] = {
 	11, 15, 22, 29, 35, 44, 59, 88
 };
 
-static int FREQ_TO_REG(const int *map, int freq)
+static int FREQ_TO_REG(const int *map, unsigned long freq)
 {
 	int i;
 
@@ -463,6 +463,9 @@ static ssize_t store_vrm_reg(struct devi
 	if (err)
 		return err;
 
+	if (val > 255)
+		return -EINVAL;
+
 	data->vrm = val;
 	return count;
 }



  parent reply	other threads:[~2014-09-03 23:46 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03 22:04 [PATCH 3.10 00/55] 3.10.54-stable review Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 01/55] stable_kernel_rules: Add pointer to netdev-FAQ for network patches Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 02/55] HID: logitech: perform bounds checking on device_id early enough Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 03/55] HID: fix a couple of off-by-ones Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 04/55] isofs: Fix unbounded recursion when processing relocated directories Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 05/55] USB: OHCI: dont lose track of EDs when a controller dies Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 06/55] USB: serial: ftdi_sio: Annotate the current Xsens PID assignments Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 07/55] USB: serial: ftdi_sio: Add support for new Xsens devices Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 08/55] USB: ehci-pci: USB host controller support for Intel Quark X1000 Greg Kroah-Hartman
2014-09-03 22:04 ` [PATCH 3.10 09/55] USB: Fix persist resume of some SS USB devices Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 10/55] ALSA: hda - fix an external mic jack problem on a HP machine Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 11/55] ALSA: virtuoso: add Xonar Essence STX II support Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 12/55] ALSA: hda/ca0132 - Dont try loading firmware at resume when already failed Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 13/55] ALSA: hda/realtek - Avoid setting wrong COEF on ALC269 & co Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 14/55] mei: start disconnect request timer consistently Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 16/55] drm: omapdrm: fix compiler errors Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 17/55] hwmon: (sis5595) Prevent overflow problem when writing large limits Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 18/55] hwmon: (lm78) Fix overflow problems seen when writing large temperature limits Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 19/55] hwmon: (gpio-fan) Prevent overflow problem when writing large limits Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 20/55] hwmon: (ads1015) Fix off-by-one for valid channel index checking Greg Kroah-Hartman
2014-09-03 22:05 ` Greg Kroah-Hartman [this message]
2014-09-03 22:05 ` [PATCH 3.10 22/55] hwmon: (ads1015) Fix out-of-bounds array access Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 23/55] hwmon: (dme1737) Prevent overflow problem when writing large limits Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 24/55] drivers/i2c/busses: use correct type for dma_map/unmap Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 25/55] ext4: fix ext4_discard_allocated_blocks() if we cant allocate the pa struct Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 26/55] serial: core: Preserve termios c_cflag for console resume Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 27/55] crypto: ux500 - make interrupt mode plausible Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 28/55] KVM: x86: Inter-privilege level ret emulation is not implemeneted Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 29/55] KVM: x86: always exit on EOIs for interrupts listed in the IOAPIC redir table Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 30/55] KVM: nVMX: fix "acknowledge interrupt on exit" when APICv is in use Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 31/55] Revert "KVM: x86: Increase the number of fixed MTRR regs to 10" Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 32/55] kvm: iommu: fix the third parameter of kvm_iommu_put_pages (CVE-2014-3601) Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 33/55] ext4: fix BUG_ON in mb_free_blocks() Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 34/55] drm/radeon: add additional SI pci ids Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 35/55] x86: dont exclude low BIOS area when allocating address space for non-PCI cards Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 36/55] x86_64/vsyscall: Fix warn_bad_vsyscall log output Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 38/55] hpsa: fix bad -ENOMEM return value in hpsa_big_passthru_ioctl Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 39/55] Btrfs: fix csum tree corruption, duplicate and outdated checksums Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 40/55] mei: reset client state on queued connect request Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 41/55] mei: nfc: fix memory leak in error path Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 42/55] jbd2: fix infinite loop when recovering corrupt journal blocks Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 43/55] Staging: speakup: Update __speakup_paste_selection() tty (ab)usage to match vt Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 44/55] xhci: Treat not finding the event_seg on COMP_STOP the same as COMP_STOP_INVAL Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 45/55] usb: xhci: amd chipset also needs short TX quirk Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 46/55] ARM: OMAP2+: hwmod: Rearm wake-up interrupts for DT when MUSB is idled Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 47/55] USB: ftdi_sio: add Basic Micro ATOM Nano USB2Serial PID Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 49/55] USB: whiteheat: Added bounds checking for bulk command response Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 50/55] usb: hub: Prevent hub autosuspend if usbcore.autosuspend is -1 Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 51/55] NFSD: Decrease nfsd_users in nfsd_startup_generic fail Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 52/55] svcrdma: Select NFSv4.1 backchannel transport based on forward channel Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 53/55] NFSv3: Fix another acl regression Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 54/55] NFSv4: Fix problems with close in the presence of a delegation Greg Kroah-Hartman
2014-09-03 22:05 ` [PATCH 3.10 55/55] vm_is_stack: use for_each_thread() rather then buggy while_each_thread() Greg Kroah-Hartman
2014-09-03 22:41 ` [PATCH 3.10 00/55] 3.10.54-stable review Greg Kroah-Hartman
2014-09-03 23:44 ` Greg Kroah-Hartman
2014-09-04  4:50   ` Guenter Roeck
2014-09-04 14:02     ` Greg Kroah-Hartman
2014-09-04 13:36 ` Shuah Khan
2014-09-04 13:52   ` Usyskin, Alexander
2014-09-04 13:52     ` Usyskin, Alexander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140903220457.313895831@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=axel.lin@ingics.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.