linux/rust/kernel
Priya Bala Govindasamy 19c76bdd3f rust: cpufreq: Fix temporary write in Registration::bios_limit_callback
In `Registration::bios_limit_callback`, the expression
`&mut (unsafe { *limit })` creates a reference to a temporary copy
of the value pointed to by `limit` on the stack.
Therefore, writes made by `T::bios_limit` go to this temporary
instead of the memory location pointed to by `limit`.

Additionally, `limit` may be uninitialized, such as when
`Registration::bios_limit_callback` is invoked by `show_bios_limit`
in drivers/cpufreq/cpufreq.c. Therefore creating a reference to
`limit` is unsound.

Fix this by changing the signature of `T::bios_limit` to return the limit
value.
`Registration::bios_limit_callback` can then update `limit` directly.

Fixes: c6af9a1191 ("rust: cpufreq: Extend abstractions for driver registration")
Reported-by: Dylan Zueck<dzueck@uci.edu>
Reported-by: Yuan Tan<ytan089@ucr.edu>
Assisted-by: ChatGPT:gpt-5.4
Signed-off-by: Priya Bala Govindasamy<pgovind2@uci.edu>
[ Viresh: Fix rustfmtcheck warning ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2026-08-06 11:54:41 +05:30
..
alloc Driver core changes for 7.2-rc1 2026-06-15 12:41:17 +05:30
block rust: block: fix GenDisk cleanup paths 2026-05-31 19:45:06 -06:00
debugfs
device
drm rust/drm/gem: Use DeviceContext with GEM objects 2026-06-02 22:51:16 +02:00
fs
gpu
interop
io Driver core changes for 7.2-rc1 2026-06-15 12:41:17 +05:30
iommu
irq
list Locking updates for v7.1: 2026-04-14 12:36:25 -07:00
mm mm: rename zap_page_range_single() to zap_vma_range() 2026-04-05 13:53:15 -07:00
net rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00
num rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00
pci rust: pci: make Bar lifetime-parameterized 2026-05-27 16:24:23 +02:00
ptr rust: ptr: remove implicit index projection syntax 2026-06-05 10:16:47 +02:00
str
sync Locking updates for v7.2: 2026-06-15 14:21:14 +05:30
time
types rust: types: add ForLt trait for higher-ranked lifetime support 2026-05-27 16:24:59 +02:00
.gitignore
acpi.rs
alloc.rs rust: alloc: cleanup imports and use "kernel vertical" style 2026-05-20 17:34:17 +02:00
auxiliary.rs rust: auxiliary: generalize Registration over ForLt 2026-05-27 16:27:28 +02:00
bitfield.rs rust: bitfield: mark Debug impl as #[inline] 2026-06-17 01:32:56 +02:00
bitmap.rs rust: tests: add Kconfig for KUnit test 2026-06-08 02:30:33 +02:00
bits.rs
block.rs
bug.rs
build_assert.rs rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00
clk.rs rust: clk: implement Send and Sync 2026-04-03 11:57:35 +02:00
configfs.rs
cpu.rs
cpufreq.rs rust: cpufreq: Fix temporary write in Registration::bios_limit_callback 2026-08-06 11:54:41 +05:30
cpumask.rs
cred.rs
debugfs.rs
device_id.rs
device.rs rust: device: make Core and CoreInternal lifetime-parameterized 2026-05-27 16:22:42 +02:00
devres.rs rust: devres: add 'static bound to Devres<T> 2026-05-29 01:06:10 +02:00
dma.rs Driver core changes for 7.2-rc1 2026-06-15 12:41:17 +05:30
driver.rs Merge patch series "rust: device: Higher-Ranked Lifetime Types for device drivers" 2026-05-29 00:38:54 +02:00
error.rs rust: error: replace match + panic in const context with const expect 2026-05-28 11:08:27 +02:00
faux.rs
firmware.rs
fmt.rs rust: fmt: use vertical import style 2026-05-20 00:47:24 +02:00
fs.rs
generated_arch_reachable_asm.rs.S
generated_arch_static_branch_asm.rs.S
generated_arch_warn_asm.rs.S
gpu.rs
i2c.rs Driver core changes for 7.2-rc1 2026-06-15 12:41:17 +05:30
id_pool.rs
impl_flags.rs
init.rs rust: inline some init methods 2026-06-09 04:13:21 +02:00
interop.rs
io.rs
ioctl.rs rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00
iov.rs
irq.rs
jump_label.rs
Kconfig.test rust: bitfield: Add KUnit tests for bitfield 2026-06-09 04:13:07 +02:00
kunit.rs rust: tests: add Kconfig for KUnit test 2026-06-08 02:30:33 +02:00
lib.rs rust: extract bitfield! macro from register! 2026-06-09 04:12:51 +02:00
list.rs rust: list: hide macros from top-level kernel doc 2026-03-27 12:15:47 +01:00
maple_tree.rs
miscdevice.rs rust: miscdevice: remove redundant imports 2026-05-23 13:47:32 +02:00
mm.rs
module_param.rs rust: module_param: add missing newline to pr_warn_once 2026-06-04 16:42:34 +00:00
net.rs
num.rs
of.rs
opp.rs opp: rust: mark OPP methods as inline 2026-05-25 09:40:52 +05:30
page.rs mm.git review status for mm-hotfixes-stable..mm-stable 2026-06-19 10:14:34 -07:00
pci.rs rust: pci: make Driver trait lifetime-parameterized 2026-05-27 16:23:10 +02:00
pid_namespace.rs
platform.rs driver core: platform: set mod_name in driver registration 2026-06-08 23:28:24 +02:00
prelude.rs rust: prelude: add zerocopy{,_derive}::IntoBytes 2026-06-17 00:32:42 +02:00
print.rs
processor.rs
ptr.rs Rust timekeeping changes for v7.1 2026-04-08 10:44:11 +02:00
pwm.rs
rbtree.rs
regulator.rs
revocable.rs
safety.rs
scatterlist.rs
security.rs
seq_file.rs
sizes.rs rust: sizes: add SizeConstants trait for device address space constants 2026-04-07 12:57:50 +02:00
soc.rs
std_vendor.rs
str.rs rust: str: clean unused import for Rust >= 1.98 2026-06-10 09:07:13 +02:00
sync.rs
task.rs Char/Misc/IIO/and others driver updates for 7.1-rc1 2026-04-24 13:23:50 -07:00
time.rs
tracepoint.rs
transmute.rs rust: transmute: simplify code with Rust 1.80.0 split_at_*checked() 2026-04-07 10:00:24 +02:00
types.rs rust: types: add ForLt trait for higher-ranked lifetime support 2026-05-27 16:24:59 +02:00
uaccess.rs Char/Misc/IIO/and others driver updates for 7.1-rc1 2026-04-24 13:23:50 -07:00
usb.rs rust: usb: make Driver trait lifetime-parameterized 2026-05-27 16:23:51 +02:00
workqueue.rs
xarray.rs rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00