Skip to content

Commit 4bb1f7e

Browse files
committed
Merge tag 'char-misc-6.18-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/misc/android driver fixes for 6.18-rc3 for reported issues. Included in here are: - rust binder fixes for reported issues - mei device id addition - mei driver fixes - comedi bugfix - most usb driver bugfixes - fastrpc memory leak fix All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-6.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: most: usb: hdm_probe: Fix calling put_device() before device initialization most: usb: Fix use-after-free in hdm_disconnect binder: remove "invalid inc weak" check mei: txe: fix initialization order comedi: fix divide-by-zero in comedi_buf_munge() mei: late_bind: Fix -Wincompatible-function-pointer-types-strict misc: fastrpc: Fix dma_buf object leak in fastrpc_map_lookup mei: me: add wildcat lake P DID misc: amd-sbi: Clarify that this is a BMC driver nvmem: rcar-efuse: add missing MODULE_DEVICE_TABLE binder: Fix missing kernel-doc entries in binder.c rust_binder: report freeze notification only when fully frozen rust_binder: don't delete FreezeListener if there are pending duplicates rust_binder: freeze_notif_done should resend if wrong state rust_binder: remove warning about orphan mappings rust_binder: clean `clippy::mem_replace_with_default` warning
2 parents 4028241 + a8cc9e5 commit 4bb1f7e

File tree

14 files changed

+93
-62
lines changed

14 files changed

+93
-62
lines changed

drivers/android/binder.c

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -851,17 +851,8 @@ static int binder_inc_node_nilocked(struct binder_node *node, int strong,
851851
} else {
852852
if (!internal)
853853
node->local_weak_refs++;
854-
if (!node->has_weak_ref && list_empty(&node->work.entry)) {
855-
if (target_list == NULL) {
856-
pr_err("invalid inc weak node for %d\n",
857-
node->debug_id);
858-
return -EINVAL;
859-
}
860-
/*
861-
* See comment above
862-
*/
854+
if (!node->has_weak_ref && target_list && list_empty(&node->work.entry))
863855
binder_enqueue_work_ilocked(&node->work, target_list);
864-
}
865856
}
866857
return 0;
867858
}
@@ -2418,10 +2409,10 @@ static int binder_translate_fd(u32 fd, binder_size_t fd_offset,
24182409

24192410
/**
24202411
* struct binder_ptr_fixup - data to be fixed-up in target buffer
2421-
* @offset offset in target buffer to fixup
2422-
* @skip_size bytes to skip in copy (fixup will be written later)
2423-
* @fixup_data data to write at fixup offset
2424-
* @node list node
2412+
* @offset: offset in target buffer to fixup
2413+
* @skip_size: bytes to skip in copy (fixup will be written later)
2414+
* @fixup_data: data to write at fixup offset
2415+
* @node: list node
24252416
*
24262417
* This is used for the pointer fixup list (pf) which is created and consumed
24272418
* during binder_transaction() and is only accessed locally. No
@@ -2438,10 +2429,10 @@ struct binder_ptr_fixup {
24382429

24392430
/**
24402431
* struct binder_sg_copy - scatter-gather data to be copied
2441-
* @offset offset in target buffer
2442-
* @sender_uaddr user address in source buffer
2443-
* @length bytes to copy
2444-
* @node list node
2432+
* @offset: offset in target buffer
2433+
* @sender_uaddr: user address in source buffer
2434+
* @length: bytes to copy
2435+
* @node: list node
24452436
*
24462437
* This is used for the sg copy list (sgc) which is created and consumed
24472438
* during binder_transaction() and is only accessed locally. No
@@ -4063,14 +4054,15 @@ binder_freeze_notification_done(struct binder_proc *proc,
40634054

40644055
/**
40654056
* binder_free_buf() - free the specified buffer
4066-
* @proc: binder proc that owns buffer
4067-
* @buffer: buffer to be freed
4068-
* @is_failure: failed to send transaction
4057+
* @proc: binder proc that owns buffer
4058+
* @thread: binder thread performing the buffer release
4059+
* @buffer: buffer to be freed
4060+
* @is_failure: failed to send transaction
40694061
*
4070-
* If buffer for an async transaction, enqueue the next async
4062+
* If the buffer is for an async transaction, enqueue the next async
40714063
* transaction from the node.
40724064
*
4073-
* Cleanup buffer and free it.
4065+
* Cleanup the buffer and free it.
40744066
*/
40754067
static void
40764068
binder_free_buf(struct binder_proc *proc,

drivers/android/binder/freeze.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,22 @@ impl DeliverToRead for FreezeMessage {
106106
return Ok(true);
107107
}
108108
if freeze.is_clearing {
109-
_removed_listener = freeze_entry.remove_node();
109+
kernel::warn_on!(freeze.num_cleared_duplicates != 0);
110+
if freeze.num_pending_duplicates > 0 {
111+
// The primary freeze listener was deleted, so convert a pending duplicate back
112+
// into the primary one.
113+
freeze.num_pending_duplicates -= 1;
114+
freeze.is_pending = true;
115+
freeze.is_clearing = true;
116+
} else {
117+
_removed_listener = freeze_entry.remove_node();
118+
}
110119
drop(node_refs);
111120
writer.write_code(BR_CLEAR_FREEZE_NOTIFICATION_DONE)?;
112121
writer.write_payload(&self.cookie.0)?;
113122
Ok(true)
114123
} else {
115-
let is_frozen = freeze.node.owner.inner.lock().is_frozen;
124+
let is_frozen = freeze.node.owner.inner.lock().is_frozen.is_fully_frozen();
116125
if freeze.last_is_frozen == Some(is_frozen) {
117126
return Ok(true);
118127
}
@@ -245,8 +254,9 @@ impl Process {
245254
);
246255
return Err(EINVAL);
247256
}
248-
if freeze.is_clearing {
249-
// Immediately send another FreezeMessage for BR_CLEAR_FREEZE_NOTIFICATION_DONE.
257+
let is_frozen = freeze.node.owner.inner.lock().is_frozen.is_fully_frozen();
258+
if freeze.is_clearing || freeze.last_is_frozen != Some(is_frozen) {
259+
// Immediately send another FreezeMessage.
250260
clear_msg = Some(FreezeMessage::init(alloc, cookie));
251261
}
252262
freeze.is_pending = false;

drivers/android/binder/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ impl Node {
687687
);
688688
}
689689
if inner.freeze_list.is_empty() {
690-
_unused_capacity = mem::replace(&mut inner.freeze_list, KVVec::new());
690+
_unused_capacity = mem::take(&mut inner.freeze_list);
691691
}
692692
}
693693

drivers/android/binder/process.rs

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,33 @@ impl Mapping {
7272
const PROC_DEFER_FLUSH: u8 = 1;
7373
const PROC_DEFER_RELEASE: u8 = 2;
7474

75+
#[derive(Copy, Clone)]
76+
pub(crate) enum IsFrozen {
77+
Yes,
78+
No,
79+
InProgress,
80+
}
81+
82+
impl IsFrozen {
83+
/// Whether incoming transactions should be rejected due to freeze.
84+
pub(crate) fn is_frozen(self) -> bool {
85+
match self {
86+
IsFrozen::Yes => true,
87+
IsFrozen::No => false,
88+
IsFrozen::InProgress => true,
89+
}
90+
}
91+
92+
/// Whether freeze notifications consider this process frozen.
93+
pub(crate) fn is_fully_frozen(self) -> bool {
94+
match self {
95+
IsFrozen::Yes => true,
96+
IsFrozen::No => false,
97+
IsFrozen::InProgress => false,
98+
}
99+
}
100+
}
101+
75102
/// The fields of `Process` protected by the spinlock.
76103
pub(crate) struct ProcessInner {
77104
is_manager: bool,
@@ -98,7 +125,7 @@ pub(crate) struct ProcessInner {
98125
/// are woken up.
99126
outstanding_txns: u32,
100127
/// Process is frozen and unable to service binder transactions.
101-
pub(crate) is_frozen: bool,
128+
pub(crate) is_frozen: IsFrozen,
102129
/// Process received sync transactions since last frozen.
103130
pub(crate) sync_recv: bool,
104131
/// Process received async transactions since last frozen.
@@ -124,7 +151,7 @@ impl ProcessInner {
124151
started_thread_count: 0,
125152
defer_work: 0,
126153
outstanding_txns: 0,
127-
is_frozen: false,
154+
is_frozen: IsFrozen::No,
128155
sync_recv: false,
129156
async_recv: false,
130157
binderfs_file: None,
@@ -1260,7 +1287,7 @@ impl Process {
12601287
let is_manager = {
12611288
let mut inner = self.inner.lock();
12621289
inner.is_dead = true;
1263-
inner.is_frozen = false;
1290+
inner.is_frozen = IsFrozen::No;
12641291
inner.sync_recv = false;
12651292
inner.async_recv = false;
12661293
inner.is_manager
@@ -1346,10 +1373,6 @@ impl Process {
13461373
.alloc
13471374
.take_for_each(|offset, size, debug_id, odata| {
13481375
let ptr = offset + address;
1349-
pr_warn!(
1350-
"{}: removing orphan mapping {offset}:{size}\n",
1351-
self.pid_in_current_ns()
1352-
);
13531376
let mut alloc =
13541377
Allocation::new(self.clone(), debug_id, offset, size, ptr, false);
13551378
if let Some(data) = odata {
@@ -1371,7 +1394,7 @@ impl Process {
13711394
return;
13721395
}
13731396
inner.outstanding_txns -= 1;
1374-
inner.is_frozen && inner.outstanding_txns == 0
1397+
inner.is_frozen.is_frozen() && inner.outstanding_txns == 0
13751398
};
13761399

13771400
if wake {
@@ -1385,7 +1408,7 @@ impl Process {
13851408
let mut inner = self.inner.lock();
13861409
inner.sync_recv = false;
13871410
inner.async_recv = false;
1388-
inner.is_frozen = false;
1411+
inner.is_frozen = IsFrozen::No;
13891412
drop(inner);
13901413
msgs.send_messages();
13911414
return Ok(());
@@ -1394,7 +1417,7 @@ impl Process {
13941417
let mut inner = self.inner.lock();
13951418
inner.sync_recv = false;
13961419
inner.async_recv = false;
1397-
inner.is_frozen = true;
1420+
inner.is_frozen = IsFrozen::InProgress;
13981421

13991422
if info.timeout_ms > 0 {
14001423
let mut jiffies = kernel::time::msecs_to_jiffies(info.timeout_ms);
@@ -1408,7 +1431,7 @@ impl Process {
14081431
.wait_interruptible_timeout(&mut inner, jiffies)
14091432
{
14101433
CondVarTimeoutResult::Signal { .. } => {
1411-
inner.is_frozen = false;
1434+
inner.is_frozen = IsFrozen::No;
14121435
return Err(ERESTARTSYS);
14131436
}
14141437
CondVarTimeoutResult::Woken { jiffies: remaining } => {
@@ -1422,17 +1445,18 @@ impl Process {
14221445
}
14231446

14241447
if inner.txns_pending_locked() {
1425-
inner.is_frozen = false;
1448+
inner.is_frozen = IsFrozen::No;
14261449
Err(EAGAIN)
14271450
} else {
14281451
drop(inner);
14291452
match self.prepare_freeze_messages() {
14301453
Ok(batch) => {
1454+
self.inner.lock().is_frozen = IsFrozen::Yes;
14311455
batch.send_messages();
14321456
Ok(())
14331457
}
14341458
Err(kernel::alloc::AllocError) => {
1435-
self.inner.lock().is_frozen = false;
1459+
self.inner.lock().is_frozen = IsFrozen::No;
14361460
Err(ENOMEM)
14371461
}
14381462
}

drivers/android/binder/transaction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl Transaction {
249249

250250
if oneway {
251251
if let Some(target_node) = self.target_node.clone() {
252-
if process_inner.is_frozen {
252+
if process_inner.is_frozen.is_frozen() {
253253
process_inner.async_recv = true;
254254
if self.flags & TF_UPDATE_TXN != 0 {
255255
if let Some(t_outdated) =
@@ -270,7 +270,7 @@ impl Transaction {
270270
}
271271
}
272272

273-
if process_inner.is_frozen {
273+
if process_inner.is_frozen.is_frozen() {
274274
return Err(BinderError::new_frozen_oneway());
275275
} else {
276276
return Ok(());
@@ -280,7 +280,7 @@ impl Transaction {
280280
}
281281
}
282282

283-
if process_inner.is_frozen {
283+
if process_inner.is_frozen.is_frozen() {
284284
process_inner.sync_recv = true;
285285
return Err(BinderError::new_frozen());
286286
}

drivers/comedi/comedi_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static unsigned int comedi_buf_munge(struct comedi_subdevice *s,
317317
unsigned int count = 0;
318318
const unsigned int num_sample_bytes = comedi_bytes_per_sample(s);
319319

320-
if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) {
320+
if (!s->munge || (async->cmd.flags & CMDF_RAWDATA) || async->cmd.chanlist_len == 0) {
321321
async->munge_count += num_bytes;
322322
return num_bytes;
323323
}

drivers/misc/amd-sbi/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
config AMD_SBRMI_I2C
33
tristate "AMD side band RMI support"
44
depends on I2C
5+
depends on ARM || ARM64 || COMPILE_TEST
56
select REGMAP_I2C
67
help
78
Side band RMI over I2C support for AMD out of band management.
9+
This driver is intended to run on the BMC, not the managed node.
810

911
This driver can also be built as a module. If so, the module will
1012
be called sbrmi-i2c.

drivers/misc/fastrpc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
381381
}
382382
spin_unlock(&fl->lock);
383383

384+
dma_buf_put(buf);
385+
384386
return ret;
385387
}
386388

drivers/misc/mei/hw-me-regs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
#define MEI_DEV_ID_PTL_H 0xE370 /* Panther Lake H */
121121
#define MEI_DEV_ID_PTL_P 0xE470 /* Panther Lake P */
122122

123+
#define MEI_DEV_ID_WCL_P 0x4D70 /* Wildcat Lake P */
124+
123125
/*
124126
* MEI HW Section
125127
*/

drivers/misc/mei/mei_lb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ static bool mei_lb_check_response(const struct device *dev, ssize_t bytes,
134134
return true;
135135
}
136136

137-
static int mei_lb_push_payload(struct device *dev,
138-
enum intel_lb_type type, u32 flags,
137+
static int mei_lb_push_payload(struct device *dev, u32 type, u32 flags,
139138
const void *payload, size_t payload_size)
140139
{
141140
struct mei_cl_device *cldev;

0 commit comments

Comments
 (0)