Skip to content

Commit eadc21f

Browse files
committed
Merge tag 'staging-4.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging / IIO fixes from Greg KH: "Here are some IIO driver fixes to resolve reported issues, some ozwpan fixes for some reported CVE problems, and a rtl8712 driver fix for a reported regression. All have been in linux-next successfully" * tag 'staging-4.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: staging: rtl8712: fix stack dump ozwpan: unchecked signed subtraction leads to DoS ozwpan: divide-by-zero leading to panic ozwpan: Use unsigned ints to prevent heap overflow ozwpan: Use proper check to prevent heap overflow iio: adc: twl6030-gpadc: Fix modalias iio: adis16400: Fix burst transfer for adis16448 iio: adis16400: Fix burst mode iio: adis16400: Compute the scan mask from channel indices iio: adis16400: Use != channel indices for the two voltage channels iio: adis16400: Report pressure channel scale
2 parents b334b77 + 39a6e73 commit eadc21f

File tree

12 files changed

+148
-110
lines changed

12 files changed

+148
-110
lines changed

drivers/iio/adc/twl6030-gpadc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ static struct platform_driver twl6030_gpadc_driver = {
10011001

10021002
module_platform_driver(twl6030_gpadc_driver);
10031003

1004-
MODULE_ALIAS("platform: " DRIVER_NAME);
1004+
MODULE_ALIAS("platform:" DRIVER_NAME);
10051005
MODULE_AUTHOR("Balaji T K <[email protected]>");
10061006
MODULE_AUTHOR("Graeme Gregory <[email protected]>");
10071007
MODULE_AUTHOR("Oleksandr Kozaruk <[email protected]");

drivers/iio/imu/adis16400.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
#define ADIS16400_NO_BURST BIT(1)
140140
#define ADIS16400_HAS_SLOW_MODE BIT(2)
141141
#define ADIS16400_HAS_SERIAL_NUMBER BIT(3)
142+
#define ADIS16400_BURST_DIAG_STAT BIT(4)
142143

143144
struct adis16400_state;
144145

@@ -165,6 +166,7 @@ struct adis16400_state {
165166
int filt_int;
166167

167168
struct adis adis;
169+
unsigned long avail_scan_mask[2];
168170
};
169171

170172
/* At the moment triggers are only used for ring buffer

drivers/iio/imu/adis16400_buffer.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,38 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
1818
{
1919
struct adis16400_state *st = iio_priv(indio_dev);
2020
struct adis *adis = &st->adis;
21-
uint16_t *tx;
21+
unsigned int burst_length;
22+
u8 *tx;
2223

2324
if (st->variant->flags & ADIS16400_NO_BURST)
2425
return adis_update_scan_mode(indio_dev, scan_mask);
2526

2627
kfree(adis->xfer);
2728
kfree(adis->buffer);
2829

30+
/* All but the timestamp channel */
31+
burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
32+
if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
33+
burst_length += sizeof(u16);
34+
2935
adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);
3036
if (!adis->xfer)
3137
return -ENOMEM;
3238

33-
adis->buffer = kzalloc(indio_dev->scan_bytes + sizeof(u16),
34-
GFP_KERNEL);
39+
adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
3540
if (!adis->buffer)
3641
return -ENOMEM;
3742

38-
tx = adis->buffer + indio_dev->scan_bytes;
39-
43+
tx = adis->buffer + burst_length;
4044
tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);
4145
tx[1] = 0;
4246

4347
adis->xfer[0].tx_buf = tx;
4448
adis->xfer[0].bits_per_word = 8;
4549
adis->xfer[0].len = 2;
46-
adis->xfer[1].tx_buf = tx;
50+
adis->xfer[1].rx_buf = adis->buffer;
4751
adis->xfer[1].bits_per_word = 8;
48-
adis->xfer[1].len = indio_dev->scan_bytes;
52+
adis->xfer[1].len = burst_length;
4953

5054
spi_message_init(&adis->msg);
5155
spi_message_add_tail(&adis->xfer[0], &adis->msg);
@@ -61,6 +65,7 @@ irqreturn_t adis16400_trigger_handler(int irq, void *p)
6165
struct adis16400_state *st = iio_priv(indio_dev);
6266
struct adis *adis = &st->adis;
6367
u32 old_speed_hz = st->adis.spi->max_speed_hz;
68+
void *buffer;
6469
int ret;
6570

6671
if (!adis->buffer)
@@ -81,7 +86,12 @@ irqreturn_t adis16400_trigger_handler(int irq, void *p)
8186
spi_setup(st->adis.spi);
8287
}
8388

84-
iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
89+
if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
90+
buffer = adis->buffer + sizeof(u16);
91+
else
92+
buffer = adis->buffer;
93+
94+
iio_push_to_buffers_with_timestamp(indio_dev, buffer,
8595
pf->timestamp);
8696

8797
iio_trigger_notify_done(indio_dev->trig);

drivers/iio/imu/adis16400_core.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
405405
*val = st->variant->temp_scale_nano / 1000000;
406406
*val2 = (st->variant->temp_scale_nano % 1000000);
407407
return IIO_VAL_INT_PLUS_MICRO;
408+
case IIO_PRESSURE:
409+
/* 20 uBar = 0.002kPascal */
410+
*val = 0;
411+
*val2 = 2000;
412+
return IIO_VAL_INT_PLUS_MICRO;
408413
default:
409414
return -EINVAL;
410415
}
@@ -454,10 +459,10 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
454459
}
455460
}
456461

457-
#define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si) { \
462+
#define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si, chn) { \
458463
.type = IIO_VOLTAGE, \
459464
.indexed = 1, \
460-
.channel = 0, \
465+
.channel = chn, \
461466
.extend_name = name, \
462467
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
463468
BIT(IIO_CHAN_INFO_SCALE), \
@@ -474,10 +479,10 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
474479
}
475480

476481
#define ADIS16400_SUPPLY_CHAN(addr, bits) \
477-
ADIS16400_VOLTAGE_CHAN(addr, bits, "supply", ADIS16400_SCAN_SUPPLY)
482+
ADIS16400_VOLTAGE_CHAN(addr, bits, "supply", ADIS16400_SCAN_SUPPLY, 0)
478483

479484
#define ADIS16400_AUX_ADC_CHAN(addr, bits) \
480-
ADIS16400_VOLTAGE_CHAN(addr, bits, NULL, ADIS16400_SCAN_ADC)
485+
ADIS16400_VOLTAGE_CHAN(addr, bits, NULL, ADIS16400_SCAN_ADC, 1)
481486

482487
#define ADIS16400_GYRO_CHAN(mod, addr, bits) { \
483488
.type = IIO_ANGL_VEL, \
@@ -773,7 +778,8 @@ static struct adis16400_chip_info adis16400_chips[] = {
773778
.channels = adis16448_channels,
774779
.num_channels = ARRAY_SIZE(adis16448_channels),
775780
.flags = ADIS16400_HAS_PROD_ID |
776-
ADIS16400_HAS_SERIAL_NUMBER,
781+
ADIS16400_HAS_SERIAL_NUMBER |
782+
ADIS16400_BURST_DIAG_STAT,
777783
.gyro_scale_micro = IIO_DEGREE_TO_RAD(10000), /* 0.01 deg/s */
778784
.accel_scale_micro = IIO_G_TO_M_S_2(833), /* 1/1200 g */
779785
.temp_scale_nano = 73860000, /* 0.07386 C */
@@ -791,11 +797,6 @@ static const struct iio_info adis16400_info = {
791797
.debugfs_reg_access = adis_debugfs_reg_access,
792798
};
793799

794-
static const unsigned long adis16400_burst_scan_mask[] = {
795-
~0UL,
796-
0,
797-
};
798-
799800
static const char * const adis16400_status_error_msgs[] = {
800801
[ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
801802
[ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
@@ -843,6 +844,20 @@ static const struct adis_data adis16400_data = {
843844
BIT(ADIS16400_DIAG_STAT_POWER_LOW),
844845
};
845846

847+
static void adis16400_setup_chan_mask(struct adis16400_state *st)
848+
{
849+
const struct adis16400_chip_info *chip_info = st->variant;
850+
unsigned i;
851+
852+
for (i = 0; i < chip_info->num_channels; i++) {
853+
const struct iio_chan_spec *ch = &chip_info->channels[i];
854+
855+
if (ch->scan_index >= 0 &&
856+
ch->scan_index != ADIS16400_SCAN_TIMESTAMP)
857+
st->avail_scan_mask[0] |= BIT(ch->scan_index);
858+
}
859+
}
860+
846861
static int adis16400_probe(struct spi_device *spi)
847862
{
848863
struct adis16400_state *st;
@@ -866,8 +881,10 @@ static int adis16400_probe(struct spi_device *spi)
866881
indio_dev->info = &adis16400_info;
867882
indio_dev->modes = INDIO_DIRECT_MODE;
868883

869-
if (!(st->variant->flags & ADIS16400_NO_BURST))
870-
indio_dev->available_scan_masks = adis16400_burst_scan_mask;
884+
if (!(st->variant->flags & ADIS16400_NO_BURST)) {
885+
adis16400_setup_chan_mask(st);
886+
indio_dev->available_scan_masks = st->avail_scan_mask;
887+
}
871888

872889
ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
873890
if (ret)

drivers/staging/ozwpan/ozhcd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ void oz_hcd_pd_reset(void *hpd, void *hport)
746746
/*
747747
* Context: softirq
748748
*/
749-
void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc,
750-
int length, int offset, int total_size)
749+
void oz_hcd_get_desc_cnf(void *hport, u8 req_id, u8 status, const u8 *desc,
750+
u8 length, u16 offset, u16 total_size)
751751
{
752752
struct oz_port *port = hport;
753753
struct urb *urb;
@@ -759,8 +759,8 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc,
759759
if (!urb)
760760
return;
761761
if (status == 0) {
762-
int copy_len;
763-
int required_size = urb->transfer_buffer_length;
762+
unsigned int copy_len;
763+
unsigned int required_size = urb->transfer_buffer_length;
764764

765765
if (required_size > total_size)
766766
required_size = total_size;

drivers/staging/ozwpan/ozusbif.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void oz_usb_request_heartbeat(void *hpd);
2929

3030
/* Confirmation functions.
3131
*/
32-
void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status,
33-
const u8 *desc, int length, int offset, int total_size);
32+
void oz_hcd_get_desc_cnf(void *hport, u8 req_id, u8 status,
33+
const u8 *desc, u8 length, u16 offset, u16 total_size);
3434
void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode,
3535
const u8 *data, int data_len);
3636

drivers/staging/ozwpan/ozusbsvc1.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,11 @@ static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx,
326326
struct oz_multiple_fixed *body =
327327
(struct oz_multiple_fixed *)data_hdr;
328328
u8 *data = body->data;
329-
int n = (len - sizeof(struct oz_multiple_fixed)+1)
329+
unsigned int n;
330+
if (!body->unit_size ||
331+
len < sizeof(struct oz_multiple_fixed) - 1)
332+
break;
333+
n = (len - (sizeof(struct oz_multiple_fixed) - 1))
330334
/ body->unit_size;
331335
while (n--) {
332336
oz_hcd_data_ind(usb_ctx->hport, body->endpoint,
@@ -390,10 +394,15 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt)
390394
case OZ_GET_DESC_RSP: {
391395
struct oz_get_desc_rsp *body =
392396
(struct oz_get_desc_rsp *)usb_hdr;
393-
int data_len = elt->length -
394-
sizeof(struct oz_get_desc_rsp) + 1;
395-
u16 offs = le16_to_cpu(get_unaligned(&body->offset));
396-
u16 total_size =
397+
u16 offs, total_size;
398+
u8 data_len;
399+
400+
if (elt->length < sizeof(struct oz_get_desc_rsp) - 1)
401+
break;
402+
data_len = elt->length -
403+
(sizeof(struct oz_get_desc_rsp) - 1);
404+
offs = le16_to_cpu(get_unaligned(&body->offset));
405+
total_size =
397406
le16_to_cpu(get_unaligned(&body->total_size));
398407
oz_dbg(ON, "USB_REQ_GET_DESCRIPTOR - cnf\n");
399408
oz_hcd_get_desc_cnf(usb_ctx->hport, body->req_id,

0 commit comments

Comments
 (0)