drm/radeon: free iio for atombios when driver shutdown
Subsystems (6)
Sasha Levin
maintainerPATCH 1/9 drm/radeon: free iio for atombios when driver shutdown
From: Liwei Song <[email protected]>
[ Upstream commit 4773fadedca918faec443daaca5e4ea1c0ced144 ]
Fix below kmemleak when unload radeon driver:
unreferenced object 0xffff9f8608ede200 (size 512):
comm "systemd-udevd", pid 326, jiffies 4294682822 (age 716.338s) hex dump (first 32 bytes):
00 00 00 00 c4 aa ec aa 14 ab 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000062fadebe>] kmem_cache_alloc_trace+0x2f1/0x500
[<00000000b6883cea>] atom_parse+0x117/0x230 [radeon]
[<00000000158c23fd>] radeon_atombios_init+0xab/0x170 [radeon]
[<00000000683f672e>] si_init+0x57/0x750 [radeon]
[<00000000566cc31f>] radeon_device_init+0x559/0x9c0 [radeon]
[<0000000046efabb3>] radeon_driver_load_kms+0xc1/0x1a0 [radeon]
[<00000000b5155064>] drm_dev_register+0xdd/0x1d0
[<0000000045fec835>] radeon_pci_probe+0xbd/0x100 [radeon]
[<00000000e69ecca3>] pci_device_probe+0xe1/0x160
[<0000000019484b76>] really_probe.part.0+0xc1/0x2c0
[<000000003f2649da>] __driver_probe_device+0x96/0x130
[<00000000231c5bb1>] driver_probe_device+0x24/0xf0
[<0000000000a42377>] __driver_attach+0x77/0x190
[<00000000d7574da6>] bus_for_each_dev+0x7f/0xd0
[<00000000633166d2>] driver_attach+0x1e/0x30
[<00000000313b05b8>] bus_add_driver+0x12c/0x1e0iio was allocated in atom_index_iio() called by atom_parse(), but it doesn't got released when the dirver is shutdown. Fix this kmemleak by free it in radeon_atombios_fini().
--- drivers/gpu/drm/radeon/radeon_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_device.c +1 -0
@@ -1045,6 +1045,7 @@ void radeon_atombios_fini(struct radeon_device *rdev) {if (rdev->mode_info.atom_context) {kfree (rdev->mode_info.atom_context->scratch); +kfree (rdev->mode_info.atom_context->iio); }kfree (rdev->mode_info.atom_context); rdev->mode_info.atom_context =NULL ;
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 2/9 drm/msm/dsi: Add missing check for alloc_ordered_workqueue
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 115906ca7b535afb1fe7b5406c566ccd3873f82b ]
Add check for the return value of alloc_ordered_workqueue as it may return NULL pointer and cause NULL pointer dereference.
Patchwork: https://patchwork.freedesktop.org/patch/517646/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/dsi/dsi_host.c +3 -0
@@ -1769,6 +1769,9 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)/* setup workqueue */ msm_host->workqueue =alloc_ordered_workqueue ("dsi_drm_work" ,0 ); +if (!msm_host->workqueue) +return -ENOMEM ; +INIT_WORK (&msm_host->err_work, dsi_err_worker);INIT_WORK (&msm_host->hpd_work, dsi_hpd_worker);
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 9/9 dm cache: add cond_resched() to various workqueue loops
In reply to Sasha LevinFrom: Mike Snitzer <[email protected]>
[ Upstream commit 76227f6dc805e9e960128bcc6276647361e0827c ]
Otherwise on resource constrained systems these workqueues may be too greedy.
--- drivers/md/dm-cache-target.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/dm-cache-target.c +4 -0
@@ -1952,6 +1952,7 @@ static void process_deferred_bios(struct work_struct *ws)else commit_needed =process_bio (cache, bio) || commit_needed; +cond_resched (); }if (commit_needed)
@@ -1974,6 +1975,7 @@ static void requeue_deferred_bios(struct cache *cache)while ((bio =bio_list_pop (&bios))) { bio->bi_status =BLK_STS_DM_REQUEUE ;bio_endio (bio); +cond_resched (); } }
@@ -2014,6 +2016,8 @@ static void check_migrations(struct work_struct *ws) r =mg_start (cache, op,NULL );if (r)break ; + +cond_resched (); } }
Signature · 6 lines
2.39.0 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Sasha Levin
maintainerPATCH 8/9 dm thin: add cond_resched() to various workqueue loops
In reply to Sasha LevinFrom: Mike Snitzer <[email protected]>
[ Upstream commit e4f80303c2353952e6e980b23914e4214487f2a6 ]
Otherwise on resource constrained systems these workqueues may be too greedy.
--- drivers/md/dm-thin.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/dm-thin.c +2 -0
@@ -2233,6 +2233,7 @@ static void process_thin_deferred_bios(struct thin_c *tc)throttle_work_update (&pool->throttle);dm_pool_issue_prefetches (pool->pmd); } +cond_resched (); }blk_finish_plug (&plug); }
@@ -2316,6 +2317,7 @@ static void process_thin_deferred_cells(struct thin_c *tc)else pool->process_cell (tc, cell); } +cond_resched (); }while (!list_empty (&cells)); }
Signature · 6 lines
2.39.0 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Sasha Levin
maintainerPATCH 4/9 ASoC: kirkwood: Iterate over array indexes instead of using pointer math
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit b3bcedc0402fcdc5c8624c433562d9d1882749d8 ]
Walking the dram->cs array was seen as accesses beyond the first array item by the compiler. Instead, use the array index directly. This allows for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen with GCC 13 with -fstrict-flex-arrays:
../sound/soc/kirkwood/kirkwood-dma.c: In function
'kirkwood_dma_conf_mbus_windows.constprop':../sound/soc/kirkwood/kirkwood-dma.c:90:24: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
90 | if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) {
| ~~^~~~~~--- sound/soc/kirkwood/kirkwood-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/kirkwood/kirkwood-dma.c +1 -1
@@ -90,7 +90,7 @@ kirkwood_dma_conf_mbus_windows(void __iomem *base, int win,/* try to find matching cs for current dma address */ for (i =0 ; i < dram->num_cs; i++) { -const struct mbus_dram_window *cs = dram->cs + i; +const struct mbus_dram_window *cs = &dram->cs[i];if ((cs->base &0xffff0000 ) < (dma &0xffff0000 )) {writel (cs->base &0xffff0000 , base +KIRKWOOD_AUDIO_WIN_BASE_REG (win));
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 7/9 pinctrl: at91: use devm_kasprintf() to avoid potential leaks
In reply to Sasha LevinFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 1c4e5c470a56f7f7c649c0c70e603abc1eab15c4 ]
Use devm_kasprintf() instead of kasprintf() to avoid any potential leaks. At the moment drivers have no remove functionality thus there is no need for fixes tag.
--- drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++-- drivers/pinctrl/pinctrl-at91.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-at91-pio4.c +2 -2
@@ -981,8 +981,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) pin_desc[i].number = i;/* Pin naming convention: P(bank_name)(bank_pin_number). */ - pin_desc[i].name =kasprintf (GFP_KERNEL ,"P%c%d" , - bank +'A' , line); + pin_desc[i].name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"P%c%d" , + bank +'A' , line); group->name = group_names[i] = pin_desc[i].name; group->pin = pin_desc[i].number;
drivers/pinctrl/pinctrl-at91.c +1 -1
@@ -1774,7 +1774,7 @@ static int at91_gpio_probe(struct platform_device *pdev) }for (i =0 ; i < chip->ngpio; i++) - names[i] =kasprintf (GFP_KERNEL ,"pio%c%d" , alias_idx +'A' , i); + names[i] =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"pio%c%d" , alias_idx +'A' , i); chip->names = (const char *const *)names;
Signature · 7 lines
2.39.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 6/9 regulator: s5m8767: Bounds check id indexing into arrays
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit e314e15a0b58f9d051c00b25951073bcdae61953 ]
The compiler has no way to know if "id" is within the array bounds of the regulators array. Add a check for this and a build-time check that the regulators and reg_voltage_map arrays are sized the same. Seen with GCC 13:
../drivers/regulator/s5m8767.c: In function 's5m8767_pmic_probe':../drivers/regulator/s5m8767.c:936:35: warning: array subscript [0, 36] is outside array bounds of 'struct regulator_desc[37]' [-Warray-bounds=]
936 | regulators[id].vsel_reg =
| ~~~~~~~~~~^~~~--- drivers/regulator/s5m8767.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/regulator/s5m8767.c +5 -1
@@ -918,10 +918,14 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)for (i =0 ; i < pdata->num_regulators; i++) {const struct sec_voltage_desc *desc; -int id = pdata->regulators[i].id; +unsigned int id = pdata->regulators[i].id;int enable_reg, enable_val;struct regulator_dev *rdev; +BUILD_BUG_ON (ARRAY_SIZE (regulators) !=ARRAY_SIZE (reg_voltage_map)); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (regulators))) +continue ; + desc = reg_voltage_map[id];if (desc) { regulators[id].n_voltages =
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 3/9 docs/scripts/gdb: add necessary make scripts_gdb step
In reply to Sasha LevinFrom: Jakob Koschel <[email protected]>
[ Upstream commit 6b219431037bf98c9efd49716aea9b68440477a3 ]
In order to debug the kernel successfully with gdb you need to run 'make scripts_gdb' nowadays.
This was changed with the following commit:
Commit 67274c083438340ad16c ("scripts/gdb: delay generation of gdb constants.py")
In order to have a complete guide for beginners this remark should be added to the offial documentation.
--- Documentation/dev-tools/gdb-kernel-debugging.rst | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/dev-tools/gdb-kernel-debugging.rst +4 -0
@@ -39,6 +39,10 @@ Setup this mode. In this case, you should build the kernel with CONFIG_RANDOMIZE_BASE disabled if the architecture supports KASLR. +- Build the gdb scripts (required on kernels v5.1 and above):: + + make scripts_gdb + - Enable the gdb stub of QEMU/KVM, either - at VM startup time by appending "-s" to the QEMU command line
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 5/9 regulator: max77802: Bounds check regulator id against opmode
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit 4fd8bcec5fd7c0d586206fa2f42bd67b06cdaa7e ]
Explicitly bounds-check the id before accessing the opmode array. Seen with GCC 13:
../drivers/regulator/max77802-regulator.c: In function 'max77802_enable':../drivers/regulator/max77802-regulator.c:217:29: warning: array subscript [0, 41] is outside array bounds of 'unsigned int[42]' [-Warray-bounds=]
217 | if (max77802->opmode[id] == MAX77802_OFF_PWRREQ)
| ~~~~~~~~~~~~~~~~^~~~
../drivers/regulator/max77802-regulator.c:62:22: note: while referencing 'opmode'
62 | unsigned int opmode[MAX77802_REG_MAX];
| ^~~~~~
--- drivers/regulator/max77802-regulator.c | 34 ++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/regulator/max77802-regulator.c +24 -10
@@ -107,9 +107,11 @@ static int max77802_set_suspend_disable(struct regulator_dev *rdev) {unsigned int val =MAX77802_OFF_PWRREQ ;struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);int shift =max77802_get_opmode_shift (id); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ; max77802->opmode[id] = val;return regmap_update_bits (rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val << shift);
@@ -123,7 +125,7 @@ static int max77802_set_suspend_disable(struct regulator_dev *rdev)static int max77802_set_mode (struct regulator_dev *rdev,unsigned int mode) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);unsigned int val;int shift =max77802_get_opmode_shift (id);
@@ -140,6 +142,9 @@ static int max77802_set_mode(struct regulator_dev *rdev, unsigned int mode)return -EINVAL ; } +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ; + max77802->opmode[id] = val;return regmap_update_bits (rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val << shift);
@@ -148,8 +153,10 @@ static int max77802_set_mode(struct regulator_dev *rdev, unsigned int mode)static unsigned max77802_get_mode (struct regulator_dev *rdev) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ;return max77802_map_mode (max77802->opmode[id]); }
@@ -173,10 +180,13 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev, unsigned int mode) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);unsigned int val;int shift =max77802_get_opmode_shift (id); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ; +/* * If the regulator has been disabled for suspend * then is invalid to try setting a suspend mode.
@@ -222,9 +232,11 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev,static int max77802_enable (struct regulator_dev *rdev) {struct max77802_regulator_prv *max77802 =rdev_get_drvdata (rdev); -int id =rdev_get_id (rdev); +unsigned int id =rdev_get_id (rdev);int shift =max77802_get_opmode_shift (id); +if (WARN_ON_ONCE (id >=ARRAY_SIZE (max77802->opmode))) +return -EINVAL ;if (max77802->opmode[id] ==MAX77802_OFF_PWRREQ ) max77802->opmode[id] =MAX77802_OPMODE_NORMAL ;
@@ -553,7 +565,7 @@ static int max77802_pmic_probe(struct platform_device *pdev)for (i =0 ; i <MAX77802_REG_MAX ; i++) {struct regulator_dev *rdev; -int id = regulators[i].id; +unsigned int id = regulators[i].id;int shift =max77802_get_opmode_shift (id);int ret;
@@ -571,10 +583,12 @@ static int max77802_pmic_probe(struct platform_device *pdev)* the hardware reports OFF as the regulator operating mode. * Default to operating mode NORMAL in that case. */ -if (val ==MAX77802_STATUS_OFF ) - max77802->opmode[id] =MAX77802_OPMODE_NORMAL ; -else - max77802->opmode[id] = val; +if (id <ARRAY_SIZE (max77802->opmode)) { +if (val ==MAX77802_STATUS_OFF ) + max77802->opmode[id] =MAX77802_OPMODE_NORMAL ; +else + max77802->opmode[id] = val; + } rdev =devm_regulator_register (&pdev->dev, ®ulators[i], &config);
Signature · 1 line
2.39.0