Skip to content

Commit ffb384c

Browse files
committed
Merge tag 'char-misc-6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are some small char/misc and other driver fixes for 6.0-rc4. Included in here are: - binder fixes for previous fixes, and a few more fixes uncovered by them. - iio driver fixes - soundwire driver fixes - fastrpc driver fixes for memory corruption on some hardware - peci driver fix - mhi driver fix All of these have been in linux-next with no reported problems" * tag 'char-misc-6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: binder: fix alloc->vma_vm_mm null-ptr dereference misc: fastrpc: increase maximum session count misc: fastrpc: fix memory corruption on open misc: fastrpc: fix memory corruption on probe soundwire: qcom: fix device status array range bus: mhi: host: Fix up null pointer access in mhi_irq_handler soundwire: qcom: remove duplicate reset control get iio: light: cm32181: make cm32181_pm_ops static iio: ad7292: Prevent regulator double disable dt-bindings: iio: gyroscope: bosch,bmg160: correct number of pins iio: adc: mcp3911: use correct formula for AD conversion iio: adc: mcp3911: correct "microchip,device-addr" property Revert "binder_alloc: Add missing mmap_lock calls when using the VMA" binder_alloc: Add missing mmap_lock calls when using the VMA binder: fix UAF of ref->proc caused by race condition iio: light: cm3605: Fix an error handling path in cm3605_probe() iio: adc: mcp3911: make use of the sign bit peci: cpu: Fix use-after-free in adev_release() peci: aspeed: fix error check return value of platform_get_irq()
2 parents fd59585 + 0f022aa commit ffb384c

12 files changed

Lines changed: 74 additions & 32 deletions

File tree

Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ properties:
2424

2525
interrupts:
2626
minItems: 1
27+
maxItems: 2
2728
description:
2829
Should be configured with type IRQ_TYPE_EDGE_RISING.
30+
If two interrupts are provided, expected order is INT1 and INT2.
2931

3032
required:
3133
- compatible

drivers/android/binder.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,18 @@ static int binder_inc_ref_for_node(struct binder_proc *proc,
13851385
}
13861386
ret = binder_inc_ref_olocked(ref, strong, target_list);
13871387
*rdata = ref->data;
1388+
if (ret && ref == new_ref) {
1389+
/*
1390+
* Cleanup the failed reference here as the target
1391+
* could now be dead and have already released its
1392+
* references by now. Calling on the new reference
1393+
* with strong=0 and a tmp_refs will not decrement
1394+
* the node. The new_ref gets kfree'd below.
1395+
*/
1396+
binder_cleanup_ref_olocked(new_ref);
1397+
ref = NULL;
1398+
}
1399+
13881400
binder_proc_unlock(proc);
13891401
if (new_ref && ref != new_ref)
13901402
/*

drivers/android/binder_alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ static inline void binder_alloc_set_vma(struct binder_alloc *alloc,
322322
*/
323323
if (vma) {
324324
vm_start = vma->vm_start;
325-
alloc->vma_vm_mm = vma->vm_mm;
326325
mmap_assert_write_locked(alloc->vma_vm_mm);
327326
} else {
328327
mmap_assert_locked(alloc->vma_vm_mm);
@@ -795,7 +794,6 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
795794
binder_insert_free_buffer(alloc, buffer);
796795
alloc->free_async_space = alloc->buffer_size / 2;
797796
binder_alloc_set_vma(alloc, vma);
798-
mmgrab(alloc->vma_vm_mm);
799797

800798
return 0;
801799

@@ -1091,6 +1089,8 @@ static struct shrinker binder_shrinker = {
10911089
void binder_alloc_init(struct binder_alloc *alloc)
10921090
{
10931091
alloc->pid = current->group_leader->pid;
1092+
alloc->vma_vm_mm = current->mm;
1093+
mmgrab(alloc->vma_vm_mm);
10941094
mutex_init(&alloc->mutex);
10951095
INIT_LIST_HEAD(&alloc->buffers);
10961096
}

drivers/bus/mhi/host/main.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,25 @@ irqreturn_t mhi_irq_handler(int irq_number, void *dev)
430430
{
431431
struct mhi_event *mhi_event = dev;
432432
struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl;
433-
struct mhi_event_ctxt *er_ctxt =
434-
&mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index];
433+
struct mhi_event_ctxt *er_ctxt;
435434
struct mhi_ring *ev_ring = &mhi_event->ring;
436-
dma_addr_t ptr = le64_to_cpu(er_ctxt->rp);
435+
dma_addr_t ptr;
437436
void *dev_rp;
438437

438+
/*
439+
* If CONFIG_DEBUG_SHIRQ is set, the IRQ handler will get invoked during __free_irq()
440+
* and by that time mhi_ctxt() would've freed. So check for the existence of mhi_ctxt
441+
* before handling the IRQs.
442+
*/
443+
if (!mhi_cntrl->mhi_ctxt) {
444+
dev_dbg(&mhi_cntrl->mhi_dev->dev,
445+
"mhi_ctxt has been freed\n");
446+
return IRQ_HANDLED;
447+
}
448+
449+
er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index];
450+
ptr = le64_to_cpu(er_ctxt->rp);
451+
439452
if (!is_valid_ring_ptr(ev_ring, ptr)) {
440453
dev_err(&mhi_cntrl->mhi_dev->dev,
441454
"Event ring rp points outside of the event ring\n");

drivers/iio/adc/ad7292.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,8 @@ static int ad7292_probe(struct spi_device *spi)
287287

288288
ret = devm_add_action_or_reset(&spi->dev,
289289
ad7292_regulator_disable, st);
290-
if (ret) {
291-
regulator_disable(st->reg);
290+
if (ret)
292291
return ret;
293-
}
294292

295293
ret = regulator_get_voltage(st->reg);
296294
if (ret < 0)

drivers/iio/adc/mcp3911.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
#define MCP3911_CHANNEL(x) (MCP3911_REG_CHANNEL0 + x * 3)
4141
#define MCP3911_OFFCAL(x) (MCP3911_REG_OFFCAL_CH0 + x * 6)
4242

43-
/* Internal voltage reference in uV */
44-
#define MCP3911_INT_VREF_UV 1200000
43+
/* Internal voltage reference in mV */
44+
#define MCP3911_INT_VREF_MV 1200
4545

4646
#define MCP3911_REG_READ(reg, id) ((((reg) << 1) | ((id) << 5) | (1 << 0)) & 0xff)
4747
#define MCP3911_REG_WRITE(reg, id) ((((reg) << 1) | ((id) << 5) | (0 << 0)) & 0xff)
@@ -113,6 +113,8 @@ static int mcp3911_read_raw(struct iio_dev *indio_dev,
113113
if (ret)
114114
goto out;
115115

116+
*val = sign_extend32(*val, 23);
117+
116118
ret = IIO_VAL_INT;
117119
break;
118120

@@ -137,11 +139,18 @@ static int mcp3911_read_raw(struct iio_dev *indio_dev,
137139

138140
*val = ret / 1000;
139141
} else {
140-
*val = MCP3911_INT_VREF_UV;
142+
*val = MCP3911_INT_VREF_MV;
141143
}
142144

143-
*val2 = 24;
144-
ret = IIO_VAL_FRACTIONAL_LOG2;
145+
/*
146+
* For 24bit Conversion
147+
* Raw = ((Voltage)/(Vref) * 2^23 * Gain * 1.5
148+
* Voltage = Raw * (Vref)/(2^23 * Gain * 1.5)
149+
*/
150+
151+
/* val2 = (2^23 * 1.5) */
152+
*val2 = 12582912;
153+
ret = IIO_VAL_FRACTIONAL;
145154
break;
146155
}
147156

@@ -208,7 +217,14 @@ static int mcp3911_config(struct mcp3911 *adc)
208217
u32 configreg;
209218
int ret;
210219

211-
device_property_read_u32(dev, "device-addr", &adc->dev_addr);
220+
ret = device_property_read_u32(dev, "microchip,device-addr", &adc->dev_addr);
221+
222+
/*
223+
* Fallback to "device-addr" due to historical mismatch between
224+
* dt-bindings and implementation
225+
*/
226+
if (ret)
227+
device_property_read_u32(dev, "device-addr", &adc->dev_addr);
212228
if (adc->dev_addr > 3) {
213229
dev_err(&adc->spi->dev,
214230
"invalid device address (%i). Must be in range 0-3.\n",

drivers/iio/light/cm32181.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ static int cm32181_resume(struct device *dev)
505505
cm32181->conf_regs[CM32181_REG_ADDR_CMD]);
506506
}
507507

508-
DEFINE_SIMPLE_DEV_PM_OPS(cm32181_pm_ops, cm32181_suspend, cm32181_resume);
508+
static DEFINE_SIMPLE_DEV_PM_OPS(cm32181_pm_ops, cm32181_suspend, cm32181_resume);
509509

510510
static const struct of_device_id cm32181_of_match[] = {
511511
{ .compatible = "capella,cm3218" },

drivers/iio/light/cm3605.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ static int cm3605_probe(struct platform_device *pdev)
226226
}
227227

228228
irq = platform_get_irq(pdev, 0);
229-
if (irq < 0)
230-
return dev_err_probe(dev, irq, "failed to get irq\n");
229+
if (irq < 0) {
230+
ret = dev_err_probe(dev, irq, "failed to get irq\n");
231+
goto out_disable_aset;
232+
}
231233

232234
ret = devm_request_threaded_irq(dev, irq, cm3605_prox_irq,
233235
NULL, 0, "cm3605", indio_dev);

drivers/misc/fastrpc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define SDSP_DOMAIN_ID (2)
2626
#define CDSP_DOMAIN_ID (3)
2727
#define FASTRPC_DEV_MAX 4 /* adsp, mdsp, slpi, cdsp*/
28-
#define FASTRPC_MAX_SESSIONS 13 /*12 compute, 1 cpz*/
28+
#define FASTRPC_MAX_SESSIONS 14
2929
#define FASTRPC_MAX_VMIDS 16
3030
#define FASTRPC_ALIGN 128
3131
#define FASTRPC_MAX_FDLIST 16
@@ -1943,7 +1943,12 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
19431943
of_property_read_u32(dev->of_node, "qcom,nsessions", &sessions);
19441944

19451945
spin_lock_irqsave(&cctx->lock, flags);
1946-
sess = &cctx->session[cctx->sesscount];
1946+
if (cctx->sesscount >= FASTRPC_MAX_SESSIONS) {
1947+
dev_err(&pdev->dev, "too many sessions\n");
1948+
spin_unlock_irqrestore(&cctx->lock, flags);
1949+
return -ENOSPC;
1950+
}
1951+
sess = &cctx->session[cctx->sesscount++];
19471952
sess->used = false;
19481953
sess->valid = true;
19491954
sess->dev = dev;
@@ -1956,13 +1961,12 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
19561961
struct fastrpc_session_ctx *dup_sess;
19571962

19581963
for (i = 1; i < sessions; i++) {
1959-
if (cctx->sesscount++ >= FASTRPC_MAX_SESSIONS)
1964+
if (cctx->sesscount >= FASTRPC_MAX_SESSIONS)
19601965
break;
1961-
dup_sess = &cctx->session[cctx->sesscount];
1966+
dup_sess = &cctx->session[cctx->sesscount++];
19621967
memcpy(dup_sess, sess, sizeof(*dup_sess));
19631968
}
19641969
}
1965-
cctx->sesscount++;
19661970
spin_unlock_irqrestore(&cctx->lock, flags);
19671971
rc = dma_set_mask(dev, DMA_BIT_MASK(32));
19681972
if (rc) {

drivers/peci/controller/peci-aspeed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int aspeed_peci_probe(struct platform_device *pdev)
523523
return PTR_ERR(priv->base);
524524

525525
priv->irq = platform_get_irq(pdev, 0);
526-
if (!priv->irq)
526+
if (priv->irq < 0)
527527
return priv->irq;
528528

529529
ret = devm_request_irq(&pdev->dev, priv->irq, aspeed_peci_irq_handler,

0 commit comments

Comments
 (0)