Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1837339ybl; Wed, 28 Aug 2019 22:53:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrBC8DpUWT6auJjIcmH2elPwCMYSZ6hXnG7l+LgpJxotkZOPBM8rjX+zRIhe0vjps6szPM X-Received: by 2002:a65:5188:: with SMTP id h8mr6708681pgq.294.1567058011998; Wed, 28 Aug 2019 22:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567058011; cv=none; d=google.com; s=arc-20160816; b=EOppI63g0m9eV53D5Yuv5lBYELbqJBxTURERDv4Jd1ijzN5aO/jXeDGvvJF1LcAGqb XVksk870jcD2FEh/h5KbFm24tQeQkTuvaXFkPaHK2gfBZr+udYvfEfnS0jTD6ut06ZUP ir9sKPxBpgCS+ppB7Hjk9beknrMU3ImEJaaLt2vtSJc3geDiP1/vol1cM1fD86ST12Bz e+RrAtWM4PkTKG4CppaIeL98FscHgpxRPgQSZgEEhTIs4JthJZmjl4k6BPKYsQvAe8mZ tFpP0KiNWRpvOubSfi3qBcz3etq4XLCWk72rjWkBd8f8tirp0E9N+MMJhdgrByye9jFn 3rhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:references :in-reply-to:message-id:date:subject:cc:to:from; bh=+65nrHwSYQ00bcOycOTlM6oZMJUC2jkOCSoleDLnaVI=; b=tHX9eMg7fDh8EJm30OL7m8YFe7Vllz+gLFEoJgN7A1Y8vYVOuZ8KUa0k2/2EJZRi8Z kc/yUyKkoKiCzfJuPNdGdi8l5jsL8X/OiTS7I8JG7gXcSlUvW+i/RpVDu2LveeVNCGgE Vm5hND+dpX4wMielR85EiV6VVbstkNn9ie+9zjETbjCAScGntQ7FFmn/eAeCsnBUZnBJ 6BLImobTpAJlGSMm4K7i0H44BhQHRzVHRoekJro6EiBHWikDtnWQEZkW/eW1tFJWJQ4U 8awU4iZjWK6/CfW8by4F6/XXjmfAlR12jkNngDdjK8u3vSCqHpMxmkcqxNbwaw649wbd aNWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u29si1027372pgm.325.2019.08.28.22.53.16; Wed, 28 Aug 2019 22:53:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727372AbfH2FvE (ORCPT + 99 others); Thu, 29 Aug 2019 01:51:04 -0400 Received: from comms.puri.sm ([159.203.221.185]:49584 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbfH2FvE (ORCPT ); Thu, 29 Aug 2019 01:51:04 -0400 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 8F372E04AD; Wed, 28 Aug 2019 22:51:03 -0700 (PDT) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8RPJF6EW5_xT; Wed, 28 Aug 2019 22:51:02 -0700 (PDT) From: Martin Kepplinger To: jic23@kernel.org, lorenzo@kernel.org, lorenzo.bianconi@redhat.com Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] Revert "iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1" Date: Thu, 29 Aug 2019 07:50:24 +0200 Message-Id: <20190829055024.559-1-martin.kepplinger@puri.sm> In-Reply-To: <37cb0888-50b6-40d2-1289-a78499a90b7c@puri.sm> References: <37cb0888-50b6-40d2-1289-a78499a90b7c@puri.sm> Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The st_lsm6dsx_sensor_settings struct's fs_avl[] array is expected to be of size 4. We can't define it to be of size 3 and try to access the 4th element below. Commit c8d4066c7246 ("iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1") which is a "cleanup" change, results in an Ooops here so revert it. Signed-off-by: Martin Kepplinger --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 2d3495560136..499745424c1e 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -151,9 +151,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x10, .mask = GENMASK(4, 3), }, - .fs_avl[0] = { IIO_DEGREE_TO_RAD(245), 0x0 }, - .fs_avl[1] = { IIO_DEGREE_TO_RAD(500), 0x1 }, - .fs_avl[2] = { IIO_DEGREE_TO_RAD(2000), 0x3 }, + .fs_avl[0] = { IIO_DEGREE_TO_RAD(245), 0x0 }, + .fs_avl[1] = { IIO_DEGREE_TO_RAD(500), 0x1 }, + .fs_avl[2] = { IIO_DEGREE_TO_RAD(0), 0x2 }, + .fs_avl[3] = { IIO_DEGREE_TO_RAD(2000), 0x3 }, }, }, }, @@ -1195,19 +1196,13 @@ static ssize_t st_lsm6dsx_sysfs_scale_avail(struct device *dev, char *buf) { struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev)); - const struct st_lsm6dsx_fs_table_entry *fs_table; enum st_lsm6dsx_sensor_id id = sensor->id; struct st_lsm6dsx_hw *hw = sensor->hw; int i, len = 0; - fs_table = &hw->settings->fs_table[id]; - for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++) { - if (!fs_table->fs_avl[i].gain) - break; - + for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++) len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ", - fs_table->fs_avl[i].gain); - } + hw->settings->fs_table[id].fs_avl[i].gain); buf[len - 1] = '\n'; return len; -- 2.20.1