Skip to content

Commit 1e5e062

Browse files
committed
Merge tag 'driver-core-6.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core
Pull driver core fixes from Danilo Krummrich: - Introduce DMA Rust helpers to avoid build errors when !CONFIG_HAS_DMA - Remove unnecessary (and hence incorrect) endian conversion in the Rust PCI driver sample code - Fix memory leak in the unwind path of debugfs_change_name() - Support non-const struct software_node pointers in SOFTWARE_NODE_REFERENCE(), after introducing _Generic() - Avoid NULL pointer dereference in the unwind path of simple_xattrs_free() * tag 'driver-core-6.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core: fs/kernfs: null-ptr deref in simple_xattrs_free() software node: Also support referencing non-constant software nodes debugfs: Fix memleak in debugfs_change_name(). samples: rust: fix endianness issue in rust_driver_pci rust: dma: add helpers for architectures without CONFIG_HAS_DMA
2 parents b63f4a4 + 2b74209 commit 1e5e062

5 files changed

Lines changed: 32 additions & 5 deletions

File tree

fs/debugfs/inode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,10 @@ int __printf(2, 3) debugfs_change_name(struct dentry *dentry, const char *fmt, .
841841
rd.new_parent = rd.old_parent;
842842
rd.flags = RENAME_NOREPLACE;
843843
target = lookup_noperm_unlocked(&QSTR(new_name), rd.new_parent);
844-
if (IS_ERR(target))
845-
return PTR_ERR(target);
844+
if (IS_ERR(target)) {
845+
error = PTR_ERR(target);
846+
goto out_free;
847+
}
846848

847849
error = start_renaming_two_dentries(&rd, dentry, target);
848850
if (error) {
@@ -862,6 +864,7 @@ int __printf(2, 3) debugfs_change_name(struct dentry *dentry, const char *fmt, .
862864
out:
863865
dput(rd.old_parent);
864866
dput(target);
867+
out_free:
865868
kfree_const(new_name);
866869
return error;
867870
}

fs/kernfs/dir.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,10 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
681681
return kn;
682682

683683
err_out4:
684-
simple_xattrs_free(&kn->iattr->xattrs, NULL);
685-
kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
684+
if (kn->iattr) {
685+
simple_xattrs_free(&kn->iattr->xattrs, NULL);
686+
kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
687+
}
686688
err_out3:
687689
spin_lock(&root->kernfs_idr_lock);
688690
idr_remove(&root->ino_idr, (u32)kernfs_ino(kn));

include/linux/property.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ struct software_node_ref_args {
371371
(const struct software_node_ref_args) { \
372372
.swnode = _Generic(_ref_, \
373373
const struct software_node *: _ref_, \
374+
struct software_node *: _ref_, \
374375
default: NULL), \
375376
.fwnode = _Generic(_ref_, \
376377
struct fwnode_handle *: _ref_, \

rust/helpers/dma.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,24 @@ int rust_helper_dma_set_mask_and_coherent(struct device *dev, u64 mask)
1919
{
2020
return dma_set_mask_and_coherent(dev, mask);
2121
}
22+
23+
int rust_helper_dma_set_mask(struct device *dev, u64 mask)
24+
{
25+
return dma_set_mask(dev, mask);
26+
}
27+
28+
int rust_helper_dma_set_coherent_mask(struct device *dev, u64 mask)
29+
{
30+
return dma_set_coherent_mask(dev, mask);
31+
}
32+
33+
int rust_helper_dma_map_sgtable(struct device *dev, struct sg_table *sgt,
34+
enum dma_data_direction dir, unsigned long attrs)
35+
{
36+
return dma_map_sgtable(dev, sgt, dir, attrs);
37+
}
38+
39+
size_t rust_helper_dma_max_mapping_size(struct device *dev)
40+
{
41+
return dma_max_mapping_size(dev);
42+
}

samples/rust/rust_driver_pci.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl SampleDriver {
4848
// Select the test.
4949
bar.write8(index.0, Regs::TEST);
5050

51-
let offset = u32::from_le(bar.read32(Regs::OFFSET)) as usize;
51+
let offset = bar.read32(Regs::OFFSET) as usize;
5252
let data = bar.read8(Regs::DATA);
5353

5454
// Write `data` to `offset` to increase `count` by one.

0 commit comments

Comments
 (0)