Skip to content

Commit 8573616

Browse files
committed
Merge tag 'char-misc-5.15-rc3' 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 and misc driver fixes for 5.15-rc3. Nothing huge in here, just fixes for a number of small issues that have been reported. These include: - habanalabs race conditions and other bugs fixed - binder driver fixes - fpga driver fixes - coresight build warning fix - nvmem driver fix - comedi memory leak fix - bcm-vk tty race fix - other tiny driver fixes All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-5.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (21 commits) comedi: Fix memory leak in compat_insnlist() nvmem: NVMEM_NINTENDO_OTP should depend on WII misc: bcm-vk: fix tty registration race fpga: dfl: Avoid reads to AFU CSRs during enumeration fpga: machxo2-spi: Fix missing error code in machxo2_write_complete() fpga: machxo2-spi: Return an error on failure habanalabs: expose a single cs seq in staged submissions habanalabs: fix wait offset handling habanalabs: rate limit multi CS completion errors habanalabs/gaudi: fix LBW RR configuration habanalabs: Fix spelling mistake "FEADBACK" -> "FEEDBACK" habanalabs: fail collective wait when not supported habanalabs/gaudi: use direct MSI in single mode habanalabs: fix kernel OOPs related to staged cs habanalabs: fix potential race in interrupt wait ioctl mcb: fix error handling in mcb_alloc_bus() misc: genwqe: Fixes DMA mask setting coresight: syscfg: Fix compiler warning nvmem: core: Add stubs for nvmem_cell_read_variable_le_u32/64 if !CONFIG_NVMEM binder: make sure fd closes complete ...
2 parents 9cbef30 + bb509a6 commit 8573616

File tree

17 files changed

+229
-103
lines changed

17 files changed

+229
-103
lines changed

drivers/android/binder.c

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,7 @@ static void binder_deferred_fd_close(int fd)
18521852
}
18531853

18541854
static void binder_transaction_buffer_release(struct binder_proc *proc,
1855+
struct binder_thread *thread,
18551856
struct binder_buffer *buffer,
18561857
binder_size_t failed_at,
18571858
bool is_failure)
@@ -2011,8 +2012,16 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
20112012
&proc->alloc, &fd, buffer,
20122013
offset, sizeof(fd));
20132014
WARN_ON(err);
2014-
if (!err)
2015+
if (!err) {
20152016
binder_deferred_fd_close(fd);
2017+
/*
2018+
* Need to make sure the thread goes
2019+
* back to userspace to complete the
2020+
* deferred close
2021+
*/
2022+
if (thread)
2023+
thread->looper_need_return = true;
2024+
}
20162025
}
20172026
} break;
20182027
default:
@@ -3038,9 +3047,8 @@ static void binder_transaction(struct binder_proc *proc,
30383047
if (reply) {
30393048
binder_enqueue_thread_work(thread, tcomplete);
30403049
binder_inner_proc_lock(target_proc);
3041-
if (target_thread->is_dead || target_proc->is_frozen) {
3042-
return_error = target_thread->is_dead ?
3043-
BR_DEAD_REPLY : BR_FROZEN_REPLY;
3050+
if (target_thread->is_dead) {
3051+
return_error = BR_DEAD_REPLY;
30443052
binder_inner_proc_unlock(target_proc);
30453053
goto err_dead_proc_or_thread;
30463054
}
@@ -3105,7 +3113,7 @@ static void binder_transaction(struct binder_proc *proc,
31053113
err_copy_data_failed:
31063114
binder_free_txn_fixups(t);
31073115
trace_binder_transaction_failed_buffer_release(t->buffer);
3108-
binder_transaction_buffer_release(target_proc, t->buffer,
3116+
binder_transaction_buffer_release(target_proc, NULL, t->buffer,
31093117
buffer_offset, true);
31103118
if (target_node)
31113119
binder_dec_node_tmpref(target_node);
@@ -3184,7 +3192,9 @@ static void binder_transaction(struct binder_proc *proc,
31843192
* Cleanup buffer and free it.
31853193
*/
31863194
static void
3187-
binder_free_buf(struct binder_proc *proc, struct binder_buffer *buffer)
3195+
binder_free_buf(struct binder_proc *proc,
3196+
struct binder_thread *thread,
3197+
struct binder_buffer *buffer)
31883198
{
31893199
binder_inner_proc_lock(proc);
31903200
if (buffer->transaction) {
@@ -3212,7 +3222,7 @@ binder_free_buf(struct binder_proc *proc, struct binder_buffer *buffer)
32123222
binder_node_inner_unlock(buf_node);
32133223
}
32143224
trace_binder_transaction_buffer_release(buffer);
3215-
binder_transaction_buffer_release(proc, buffer, 0, false);
3225+
binder_transaction_buffer_release(proc, thread, buffer, 0, false);
32163226
binder_alloc_free_buf(&proc->alloc, buffer);
32173227
}
32183228

@@ -3414,7 +3424,7 @@ static int binder_thread_write(struct binder_proc *proc,
34143424
proc->pid, thread->pid, (u64)data_ptr,
34153425
buffer->debug_id,
34163426
buffer->transaction ? "active" : "finished");
3417-
binder_free_buf(proc, buffer);
3427+
binder_free_buf(proc, thread, buffer);
34183428
break;
34193429
}
34203430

@@ -4107,7 +4117,7 @@ static int binder_thread_read(struct binder_proc *proc,
41074117
buffer->transaction = NULL;
41084118
binder_cleanup_transaction(t, "fd fixups failed",
41094119
BR_FAILED_REPLY);
4110-
binder_free_buf(proc, buffer);
4120+
binder_free_buf(proc, thread, buffer);
41114121
binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
41124122
"%d:%d %stransaction %d fd fixups failed %d/%d, line %d\n",
41134123
proc->pid, thread->pid,
@@ -4648,6 +4658,22 @@ static int binder_ioctl_get_node_debug_info(struct binder_proc *proc,
46484658
return 0;
46494659
}
46504660

4661+
static bool binder_txns_pending_ilocked(struct binder_proc *proc)
4662+
{
4663+
struct rb_node *n;
4664+
struct binder_thread *thread;
4665+
4666+
if (proc->outstanding_txns > 0)
4667+
return true;
4668+
4669+
for (n = rb_first(&proc->threads); n; n = rb_next(n)) {
4670+
thread = rb_entry(n, struct binder_thread, rb_node);
4671+
if (thread->transaction_stack)
4672+
return true;
4673+
}
4674+
return false;
4675+
}
4676+
46514677
static int binder_ioctl_freeze(struct binder_freeze_info *info,
46524678
struct binder_proc *target_proc)
46534679
{
@@ -4679,8 +4705,13 @@ static int binder_ioctl_freeze(struct binder_freeze_info *info,
46794705
(!target_proc->outstanding_txns),
46804706
msecs_to_jiffies(info->timeout_ms));
46814707

4682-
if (!ret && target_proc->outstanding_txns)
4683-
ret = -EAGAIN;
4708+
/* Check pending transactions that wait for reply */
4709+
if (ret >= 0) {
4710+
binder_inner_proc_lock(target_proc);
4711+
if (binder_txns_pending_ilocked(target_proc))
4712+
ret = -EAGAIN;
4713+
binder_inner_proc_unlock(target_proc);
4714+
}
46844715

46854716
if (ret < 0) {
46864717
binder_inner_proc_lock(target_proc);
@@ -4696,6 +4727,7 @@ static int binder_ioctl_get_freezer_info(
46964727
{
46974728
struct binder_proc *target_proc;
46984729
bool found = false;
4730+
__u32 txns_pending;
46994731

47004732
info->sync_recv = 0;
47014733
info->async_recv = 0;
@@ -4705,7 +4737,9 @@ static int binder_ioctl_get_freezer_info(
47054737
if (target_proc->pid == info->pid) {
47064738
found = true;
47074739
binder_inner_proc_lock(target_proc);
4708-
info->sync_recv |= target_proc->sync_recv;
4740+
txns_pending = binder_txns_pending_ilocked(target_proc);
4741+
info->sync_recv |= target_proc->sync_recv |
4742+
(txns_pending << 1);
47094743
info->async_recv |= target_proc->async_recv;
47104744
binder_inner_proc_unlock(target_proc);
47114745
}

drivers/android/binder_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ struct binder_ref {
378378
* binder transactions
379379
* (protected by @inner_lock)
380380
* @sync_recv: process received sync transactions since last frozen
381+
* bit 0: received sync transaction after being frozen
382+
* bit 1: new pending sync transaction during freezing
381383
* (protected by @inner_lock)
382384
* @async_recv: process received async transactions since last frozen
383385
* (protected by @inner_lock)

drivers/comedi/comedi_fops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,6 +3090,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)
30903090
mutex_lock(&dev->mutex);
30913091
rc = do_insnlist_ioctl(dev, insns, insnlist32.n_insns, file);
30923092
mutex_unlock(&dev->mutex);
3093+
kfree(insns);
30933094
return rc;
30943095
}
30953096

drivers/fpga/dfl.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,16 +1019,18 @@ create_feature_instance(struct build_feature_devs_info *binfo,
10191019
{
10201020
unsigned int irq_base, nr_irqs;
10211021
struct dfl_feature_info *finfo;
1022+
u8 revision = 0;
10221023
int ret;
1023-
u8 revision;
10241024
u64 v;
10251025

1026-
v = readq(binfo->ioaddr + ofst);
1027-
revision = FIELD_GET(DFH_REVISION, v);
1026+
if (fid != FEATURE_ID_AFU) {
1027+
v = readq(binfo->ioaddr + ofst);
1028+
revision = FIELD_GET(DFH_REVISION, v);
10281029

1029-
/* read feature size and id if inputs are invalid */
1030-
size = size ? size : feature_size(v);
1031-
fid = fid ? fid : feature_id(v);
1030+
/* read feature size and id if inputs are invalid */
1031+
size = size ? size : feature_size(v);
1032+
fid = fid ? fid : feature_id(v);
1033+
}
10321034

10331035
if (binfo->len - ofst < size)
10341036
return -EINVAL;

drivers/fpga/machxo2-spi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ static int machxo2_write_init(struct fpga_manager *mgr,
225225
goto fail;
226226

227227
get_status(spi, &status);
228-
if (test_bit(FAIL, &status))
228+
if (test_bit(FAIL, &status)) {
229+
ret = -EINVAL;
229230
goto fail;
231+
}
230232
dump_status_reg(&status);
231233

232234
spi_message_init(&msg);
@@ -313,6 +315,7 @@ static int machxo2_write_complete(struct fpga_manager *mgr,
313315
dump_status_reg(&status);
314316
if (!test_bit(DONE, &status)) {
315317
machxo2_cleanup(mgr);
318+
ret = -EINVAL;
316319
goto fail;
317320
}
318321

@@ -335,6 +338,7 @@ static int machxo2_write_complete(struct fpga_manager *mgr,
335338
break;
336339
if (++refreshloop == MACHXO2_MAX_REFRESH_LOOP) {
337340
machxo2_cleanup(mgr);
341+
ret = -EINVAL;
338342
goto fail;
339343
}
340344
} while (1);

drivers/hwtracing/coresight/coresight-syscfg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <linux/platform_device.h>
8+
#include <linux/slab.h>
89

910
#include "coresight-config.h"
1011
#include "coresight-etm-perf.h"

drivers/mcb/mcb-core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
275275

276276
bus_nr = ida_simple_get(&mcb_ida, 0, 0, GFP_KERNEL);
277277
if (bus_nr < 0) {
278-
rc = bus_nr;
279-
goto err_free;
278+
kfree(bus);
279+
return ERR_PTR(bus_nr);
280280
}
281281

282282
bus->bus_nr = bus_nr;
@@ -291,12 +291,12 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
291291
dev_set_name(&bus->dev, "mcb:%d", bus_nr);
292292
rc = device_add(&bus->dev);
293293
if (rc)
294-
goto err_free;
294+
goto err_put;
295295

296296
return bus;
297-
err_free:
298-
put_device(carrier);
299-
kfree(bus);
297+
298+
err_put:
299+
put_device(&bus->dev);
300300
return ERR_PTR(rc);
301301
}
302302
EXPORT_SYMBOL_NS_GPL(mcb_alloc_bus, MCB);

drivers/misc/bcm-vk/bcm_vk_tty.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,13 @@ int bcm_vk_tty_init(struct bcm_vk *vk, char *name)
267267
struct device *tty_dev;
268268

269269
tty_port_init(&vk->tty[i].port);
270-
tty_dev = tty_port_register_device(&vk->tty[i].port, tty_drv,
271-
i, dev);
270+
tty_dev = tty_port_register_device_attr(&vk->tty[i].port,
271+
tty_drv, i, dev, vk,
272+
NULL);
272273
if (IS_ERR(tty_dev)) {
273274
err = PTR_ERR(tty_dev);
274275
goto unwind;
275276
}
276-
dev_set_drvdata(tty_dev, vk);
277277
vk->tty[i].is_opened = false;
278278
}
279279

drivers/misc/genwqe/card_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ static int genwqe_pci_setup(struct genwqe_dev *cd)
10901090

10911091
/* check for 64-bit DMA address supported (DAC) */
10921092
/* check for 32-bit DMA address supported (SAC) */
1093-
if (dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(64)) ||
1093+
if (dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(64)) &&
10941094
dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(32))) {
10951095
dev_err(&pci_dev->dev,
10961096
"err: neither DMA32 nor DMA64 supported\n");

0 commit comments

Comments
 (0)