Merge b986ec200f ("soc: versatile: realview: fix soc_dev leak during device remove") into android14-6.1-lts

Steps on the way to 6.1.113

Change-Id: I8de726c0f7aac71a8b0b01802a95b0680ce31ecb
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2024-11-10 08:20:12 +00:00
25 changed files with 98 additions and 53 deletions

View File

@@ -32,12 +32,12 @@
backlight: edp-backlight { backlight: edp-backlight {
compatible = "pwm-backlight"; compatible = "pwm-backlight";
power-supply = <&vcc_12v>; power-supply = <&vcc_12v>;
pwms = <&pwm0 0 740740 0>; pwms = <&pwm0 0 125000 0>;
}; };
bat: battery { bat: battery {
compatible = "simple-battery"; compatible = "simple-battery";
charge-full-design-microamp-hours = <9800000>; charge-full-design-microamp-hours = <10000000>;
voltage-max-design-microvolt = <4350000>; voltage-max-design-microvolt = <4350000>;
voltage-min-design-microvolt = <3000000>; voltage-min-design-microvolt = <3000000>;
}; };

View File

@@ -1602,6 +1602,7 @@ static void pt_event_stop(struct perf_event *event, int mode)
* see comment in intel_pt_interrupt(). * see comment in intel_pt_interrupt().
*/ */
WRITE_ONCE(pt->handle_nmi, 0); WRITE_ONCE(pt->handle_nmi, 0);
barrier();
pt_config_stop(event); pt_config_stop(event);
@@ -1653,11 +1654,10 @@ static long pt_event_snapshot_aux(struct perf_event *event,
return 0; return 0;
/* /*
* Here, handle_nmi tells us if the tracing is on * There is no PT interrupt in this mode, so stop the trace and it will
* remain stopped while the buffer is copied.
*/ */
if (READ_ONCE(pt->handle_nmi)) pt_config_stop(event);
pt_config_stop(event);
pt_read_offset(buf); pt_read_offset(buf);
pt_update_head(pt); pt_update_head(pt);
@@ -1669,11 +1669,10 @@ static long pt_event_snapshot_aux(struct perf_event *event,
ret = perf_output_copy_aux(&pt->handle, handle, from, to); ret = perf_output_copy_aux(&pt->handle, handle, from, to);
/* /*
* If the tracing was on when we turned up, restart it. * Here, handle_nmi tells us if the tracing was on.
* Compiler barrier not needed as we couldn't have been * If the tracing was on, restart it.
* preempted by anything that touches pt->handle_nmi.
*/ */
if (pt->handle_nmi) if (READ_ONCE(pt->handle_nmi))
pt_config_start(event); pt_config_start(event);
return ret; return ret;

View File

@@ -544,8 +544,9 @@ int acpi_device_setup_files(struct acpi_device *dev)
* If device has _STR, 'description' file is created * If device has _STR, 'description' file is created
*/ */
if (acpi_has_method(dev->handle, "_STR")) { if (acpi_has_method(dev->handle, "_STR")) {
status = acpi_evaluate_object(dev->handle, "_STR", status = acpi_evaluate_object_typed(dev->handle, "_STR",
NULL, &buffer); NULL, &buffer,
ACPI_TYPE_BUFFER);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
buffer.pointer = NULL; buffer.pointer = NULL;
dev->pnp.str_obj = buffer.pointer; dev->pnp.str_obj = buffer.pointer;

View File

@@ -512,6 +512,12 @@ static const struct dmi_system_id maingear_laptop[] = {
DMI_MATCH(DMI_BOARD_NAME, "GMxXGxx"), DMI_MATCH(DMI_BOARD_NAME, "GMxXGxx"),
}, },
}, },
{
/* TongFang GMxXGxX/TUXEDO Polaris 15 Gen5 AMD */
.matches = {
DMI_MATCH(DMI_BOARD_NAME, "GMxXGxX"),
},
},
{ {
/* TongFang GMxXGxx sold as Eluktronics Inc. RP-15 */ /* TongFang GMxXGxx sold as Eluktronics Inc. RP-15 */
.matches = { .matches = {

View File

@@ -3380,10 +3380,12 @@ void drbd_uuid_new_current(struct drbd_device *device) __must_hold(local)
void drbd_uuid_set_bm(struct drbd_device *device, u64 val) __must_hold(local) void drbd_uuid_set_bm(struct drbd_device *device, u64 val) __must_hold(local)
{ {
unsigned long flags; unsigned long flags;
if (device->ldev->md.uuid[UI_BITMAP] == 0 && val == 0)
return;
spin_lock_irqsave(&device->ldev->md.uuid_lock, flags); spin_lock_irqsave(&device->ldev->md.uuid_lock, flags);
if (device->ldev->md.uuid[UI_BITMAP] == 0 && val == 0) {
spin_unlock_irqrestore(&device->ldev->md.uuid_lock, flags);
return;
}
if (val == 0) { if (val == 0) {
drbd_uuid_move_history(device); drbd_uuid_move_history(device);
device->ldev->md.uuid[UI_HISTORY_START] = device->ldev->md.uuid[UI_BITMAP]; device->ldev->md.uuid[UI_HISTORY_START] = device->ldev->md.uuid[UI_BITMAP];

View File

@@ -876,7 +876,7 @@ is_valid_state(struct drbd_device *device, union drbd_state ns)
ns.disk == D_OUTDATED) ns.disk == D_OUTDATED)
rv = SS_CONNECTED_OUTDATES; rv = SS_CONNECTED_OUTDATES;
else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && else if (nc && (ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
(nc->verify_alg[0] == 0)) (nc->verify_alg[0] == 0))
rv = SS_NO_VERIFY_ALG; rv = SS_NO_VERIFY_ALG;

View File

@@ -95,8 +95,10 @@ static int bcm2835_rng_init(struct hwrng *rng)
return ret; return ret;
ret = reset_control_reset(priv->reset); ret = reset_control_reset(priv->reset);
if (ret) if (ret) {
clk_disable_unprepare(priv->clk);
return ret; return ret;
}
if (priv->mask_interrupts) { if (priv->mask_interrupts) {
/* mask the interrupt */ /* mask the interrupt */

View File

@@ -665,6 +665,7 @@ static int __maybe_unused cctrng_resume(struct device *dev)
/* wait for Cryptocell reset completion */ /* wait for Cryptocell reset completion */
if (!cctrng_wait_for_reset_completion(drvdata)) { if (!cctrng_wait_for_reset_completion(drvdata)) {
dev_err(dev, "Cryptocell reset not completed"); dev_err(dev, "Cryptocell reset not completed");
clk_disable_unprepare(drvdata->clk);
return -EBUSY; return -EBUSY;
} }

View File

@@ -142,7 +142,7 @@ static int mtk_rng_probe(struct platform_device *pdev)
dev_set_drvdata(&pdev->dev, priv); dev_set_drvdata(&pdev->dev, priv);
pm_runtime_set_autosuspend_delay(&pdev->dev, RNG_AUTOSUSPEND_TIMEOUT); pm_runtime_set_autosuspend_delay(&pdev->dev, RNG_AUTOSUSPEND_TIMEOUT);
pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_enable(&pdev->dev); devm_pm_runtime_enable(&pdev->dev);
dev_info(&pdev->dev, "registered RNG driver\n"); dev_info(&pdev->dev, "registered RNG driver\n");

View File

@@ -1362,6 +1362,8 @@ void sev_pci_init(void)
return; return;
err: err:
sev_dev_destroy(psp_master);
psp_master->sev_data = NULL; psp_master->sev_data = NULL;
} }

View File

@@ -245,7 +245,7 @@ static u64 ehl_err_addr_to_imc_addr(u64 eaddr, int mc)
if (igen6_tom <= _4GB) if (igen6_tom <= _4GB)
return eaddr + igen6_tolud - _4GB; return eaddr + igen6_tolud - _4GB;
if (eaddr < _4GB) if (eaddr >= igen6_tom)
return eaddr + igen6_tolud - igen6_tom; return eaddr + igen6_tolud - igen6_tom;
return eaddr; return eaddr;

View File

@@ -115,7 +115,7 @@ void efi_retrieve_tpm2_eventlog(void)
} }
/* Allocate space for the logs and copy them. */ /* Allocate space for the logs and copy them. */
status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,
sizeof(*log_tbl) + log_size, (void **)&log_tbl); sizeof(*log_tbl) + log_size, (void **)&log_tbl);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {

View File

@@ -56,6 +56,9 @@ int mt7615_thermal_init(struct mt7615_dev *dev)
name = devm_kasprintf(&wiphy->dev, GFP_KERNEL, "mt7615_%s", name = devm_kasprintf(&wiphy->dev, GFP_KERNEL, "mt7615_%s",
wiphy_name(wiphy)); wiphy_name(wiphy));
if (!name)
return -ENOMEM;
hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, name, dev, hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, name, dev,
mt7615_hwmon_groups); mt7615_hwmon_groups);
if (IS_ERR(hwmon)) if (IS_ERR(hwmon))

View File

@@ -2593,12 +2593,14 @@ static void query_phy_status_page1(struct rtw_dev *rtwdev, u8 *phy_status,
else else
rxsc = GET_PHY_STAT_P1_HT_RXSC(phy_status); rxsc = GET_PHY_STAT_P1_HT_RXSC(phy_status);
if (rxsc >= 9 && rxsc <= 12) if (rxsc == 0)
bw = RTW_CHANNEL_WIDTH_40; bw = rtwdev->hal.current_band_width;
else if (rxsc >= 13) else if (rxsc >= 1 && rxsc <= 8)
bw = RTW_CHANNEL_WIDTH_80;
else
bw = RTW_CHANNEL_WIDTH_20; bw = RTW_CHANNEL_WIDTH_20;
else if (rxsc >= 9 && rxsc <= 12)
bw = RTW_CHANNEL_WIDTH_40;
else
bw = RTW_CHANNEL_WIDTH_80;
channel = GET_PHY_STAT_P1_CHANNEL(phy_status); channel = GET_PHY_STAT_P1_CHANNEL(phy_status);
rtw_set_rx_freq_band(pkt_stat, channel); rtw_set_rx_freq_band(pkt_stat, channel);

View File

@@ -4,6 +4,7 @@
* *
* Author: Linus Walleij <linus.walleij@linaro.org> * Author: Linus Walleij <linus.walleij@linaro.org>
*/ */
#include <linux/device.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
@@ -81,6 +82,13 @@ static struct attribute *realview_attrs[] = {
ATTRIBUTE_GROUPS(realview); ATTRIBUTE_GROUPS(realview);
static void realview_soc_socdev_release(void *data)
{
struct soc_device *soc_dev = data;
soc_device_unregister(soc_dev);
}
static int realview_soc_probe(struct platform_device *pdev) static int realview_soc_probe(struct platform_device *pdev)
{ {
struct regmap *syscon_regmap; struct regmap *syscon_regmap;
@@ -93,7 +101,7 @@ static int realview_soc_probe(struct platform_device *pdev)
if (IS_ERR(syscon_regmap)) if (IS_ERR(syscon_regmap))
return PTR_ERR(syscon_regmap); return PTR_ERR(syscon_regmap);
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr), GFP_KERNEL);
if (!soc_dev_attr) if (!soc_dev_attr)
return -ENOMEM; return -ENOMEM;
@@ -106,10 +114,14 @@ static int realview_soc_probe(struct platform_device *pdev)
soc_dev_attr->family = "Versatile"; soc_dev_attr->family = "Versatile";
soc_dev_attr->custom_attr_group = realview_groups[0]; soc_dev_attr->custom_attr_group = realview_groups[0];
soc_dev = soc_device_register(soc_dev_attr); soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR(soc_dev)) { if (IS_ERR(soc_dev))
kfree(soc_dev_attr);
return -ENODEV; return -ENODEV;
}
ret = devm_add_action_or_reset(&pdev->dev, realview_soc_socdev_release,
soc_dev);
if (ret)
return ret;
ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET, ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET,
&realview_coreid); &realview_coreid);
if (ret) if (ret)

View File

@@ -534,8 +534,10 @@ put_runtime_pm:
static void xhci_pci_remove(struct pci_dev *dev) static void xhci_pci_remove(struct pci_dev *dev)
{ {
struct xhci_hcd *xhci; struct xhci_hcd *xhci;
bool set_power_d3;
xhci = hcd_to_xhci(pci_get_drvdata(dev)); xhci = hcd_to_xhci(pci_get_drvdata(dev));
set_power_d3 = xhci->quirks & XHCI_SPURIOUS_WAKEUP;
xhci->xhc_state |= XHCI_STATE_REMOVING; xhci->xhc_state |= XHCI_STATE_REMOVING;
@@ -548,11 +550,11 @@ static void xhci_pci_remove(struct pci_dev *dev)
xhci->shared_hcd = NULL; xhci->shared_hcd = NULL;
} }
/* Workaround for spurious wakeups at shutdown with HSW */
if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
pci_set_power_state(dev, PCI_D3hot);
usb_hcd_pci_remove(dev); usb_hcd_pci_remove(dev);
/* Workaround for spurious wakeups at shutdown with HSW */
if (set_power_d3)
pci_set_power_state(dev, PCI_D3hot);
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM

View File

@@ -157,7 +157,8 @@ static unsigned long dir_block_index(unsigned int level,
unsigned long bidx = 0; unsigned long bidx = 0;
for (i = 0; i < level; i++) for (i = 0; i < level; i++)
bidx += dir_buckets(i, dir_level) * bucket_blocks(i); bidx += mul_u32_u32(dir_buckets(i, dir_level),
bucket_blocks(i));
bidx += idx * bucket_blocks(level); bidx += idx * bucket_blocks(level);
return bidx; return bidx;
} }

View File

@@ -377,7 +377,7 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi,
static void __drop_largest_extent(struct extent_tree *et, static void __drop_largest_extent(struct extent_tree *et,
pgoff_t fofs, unsigned int len) pgoff_t fofs, unsigned int len)
{ {
if (fofs < et->largest.fofs + et->largest.len && if (fofs < (pgoff_t)et->largest.fofs + et->largest.len &&
fofs + len > et->largest.fofs) { fofs + len > et->largest.fofs) {
et->largest.len = 0; et->largest.len = 0;
et->largest_updated = true; et->largest_updated = true;
@@ -467,7 +467,7 @@ static bool __lookup_extent_tree(struct inode *inode, pgoff_t pgofs,
if (type == EX_READ && if (type == EX_READ &&
et->largest.fofs <= pgofs && et->largest.fofs <= pgofs &&
et->largest.fofs + et->largest.len > pgofs) { (pgoff_t)et->largest.fofs + et->largest.len > pgofs) {
*ei = et->largest; *ei = et->largest;
ret = true; ret = true;
stat_inc_largest_node_hit(sbi); stat_inc_largest_node_hit(sbi);

View File

@@ -2648,7 +2648,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
inode_lock(inode); inode_lock(inode);
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) { if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) ||
f2fs_is_atomic_file(inode)) {
err = -EINVAL; err = -EINVAL;
goto unlock_out; goto unlock_out;
} }
@@ -2671,7 +2672,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
* block addresses are continuous. * block addresses are continuous.
*/ */
if (f2fs_lookup_read_extent_cache(inode, pg_start, &ei)) { if (f2fs_lookup_read_extent_cache(inode, pg_start, &ei)) {
if (ei.fofs + ei.len >= pg_end) if ((pgoff_t)ei.fofs + ei.len >= pg_end)
goto out; goto out;
} }
@@ -2877,6 +2878,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
goto out_unlock; goto out_unlock;
} }
if (f2fs_is_atomic_file(src) || f2fs_is_atomic_file(dst)) {
ret = -EINVAL;
goto out_unlock;
}
ret = -EINVAL; ret = -EINVAL;
if (pos_in + len > src->i_size || pos_in + len < pos_in) if (pos_in + len > src->i_size || pos_in + len < pos_in)
goto out_unlock; goto out_unlock;
@@ -3248,6 +3254,11 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)
inode_lock(inode); inode_lock(inode);
if (f2fs_is_atomic_file(inode)) {
ret = -EINVAL;
goto out;
}
if (!pin) { if (!pin) {
clear_inode_flag(inode, FI_PIN_FILE); clear_inode_flag(inode, FI_PIN_FILE);
f2fs_i_gc_failures_write(inode, 0); f2fs_i_gc_failures_write(inode, 0);

View File

@@ -3334,9 +3334,9 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
u32 segment_count = le32_to_cpu(raw_super->segment_count); u32 segment_count = le32_to_cpu(raw_super->segment_count);
u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg); u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
u64 main_end_blkaddr = main_blkaddr + u64 main_end_blkaddr = main_blkaddr +
(segment_count_main << log_blocks_per_seg); ((u64)segment_count_main << log_blocks_per_seg);
u64 seg_end_blkaddr = segment0_blkaddr + u64 seg_end_blkaddr = segment0_blkaddr +
(segment_count << log_blocks_per_seg); ((u64)segment_count << log_blocks_per_seg);
if (segment0_blkaddr != cp_blkaddr) { if (segment0_blkaddr != cp_blkaddr) {
f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)", f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)",

View File

@@ -85,8 +85,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
return error; return error;
} }
static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
int force) int force)
{ {
write_lock_irq(&filp->f_owner.lock); write_lock_irq(&filp->f_owner.lock);
if (force || !filp->f_owner.pid) { if (force || !filp->f_owner.pid) {
@@ -96,19 +96,13 @@ static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
if (pid) { if (pid) {
const struct cred *cred = current_cred(); const struct cred *cred = current_cred();
security_file_set_fowner(filp);
filp->f_owner.uid = cred->uid; filp->f_owner.uid = cred->uid;
filp->f_owner.euid = cred->euid; filp->f_owner.euid = cred->euid;
} }
} }
write_unlock_irq(&filp->f_owner.lock); write_unlock_irq(&filp->f_owner.lock);
} }
void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
int force)
{
security_file_set_fowner(filp);
f_modown(filp, pid, type, force);
}
EXPORT_SYMBOL(__f_setown); EXPORT_SYMBOL(__f_setown);
int f_setown(struct file *filp, unsigned long arg, int force) int f_setown(struct file *filp, unsigned long arg, int force)
@@ -144,7 +138,7 @@ EXPORT_SYMBOL(f_setown);
void f_delown(struct file *filp) void f_delown(struct file *filp)
{ {
f_modown(filp, NULL, PIDTYPE_TGID, 1); __f_setown(filp, NULL, PIDTYPE_TGID, 1);
} }
pid_t f_getown(struct file *filp) pid_t f_getown(struct file *filp)

View File

@@ -757,6 +757,10 @@ again:
continue; continue;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (atomic_read(&inode->i_count)) {
spin_unlock(&inode->i_lock);
continue;
}
if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
continue; continue;

View File

@@ -1953,6 +1953,7 @@ restart:
set_bit(ops->owner_flag_bit, &sp->so_flags); set_bit(ops->owner_flag_bit, &sp->so_flags);
nfs4_put_state_owner(sp); nfs4_put_state_owner(sp);
status = nfs4_recovery_handle_error(clp, status); status = nfs4_recovery_handle_error(clp, status);
nfs4_free_state_owners(&freeme);
return (status != 0) ? status : -EAGAIN; return (status != 0) ? status : -EAGAIN;
} }

View File

@@ -396,7 +396,8 @@ void padata_do_serial(struct padata_priv *padata)
/* Sort in ascending order of sequence number. */ /* Sort in ascending order of sequence number. */
list_for_each_prev(pos, &reorder->list) { list_for_each_prev(pos, &reorder->list) {
cur = list_entry(pos, struct padata_priv, list); cur = list_entry(pos, struct padata_priv, list);
if (cur->seq_nr < padata->seq_nr) /* Compare by difference to consider integer wrap around */
if ((signed int)(cur->seq_nr - padata->seq_nr) < 0)
break; break;
} }
list_add(&padata->list, pos); list_add(&padata->list, pos);

View File

@@ -141,13 +141,14 @@ static void fill_pool(void)
* READ_ONCE()s pair with the WRITE_ONCE()s in pool_lock critical * READ_ONCE()s pair with the WRITE_ONCE()s in pool_lock critical
* sections. * sections.
*/ */
while (READ_ONCE(obj_nr_tofree) && (READ_ONCE(obj_pool_free) < obj_pool_min_free)) { while (READ_ONCE(obj_nr_tofree) &&
READ_ONCE(obj_pool_free) < debug_objects_pool_min_level) {
raw_spin_lock_irqsave(&pool_lock, flags); raw_spin_lock_irqsave(&pool_lock, flags);
/* /*
* Recheck with the lock held as the worker thread might have * Recheck with the lock held as the worker thread might have
* won the race and freed the global free list already. * won the race and freed the global free list already.
*/ */
while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) { while (obj_nr_tofree && (obj_pool_free < debug_objects_pool_min_level)) {
obj = hlist_entry(obj_to_free.first, typeof(*obj), node); obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
hlist_del(&obj->node); hlist_del(&obj->node);
WRITE_ONCE(obj_nr_tofree, obj_nr_tofree - 1); WRITE_ONCE(obj_nr_tofree, obj_nr_tofree - 1);