7.3.4-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 265/1257 media: adv7180: Initialize mutex before ancillary clients
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9d46d17a65e86010b1f5604e5cf61ce1e197f77a ]
The VPP ancillary-client error path unregisters the CSI client before destroying state->mutex. For I2P variants, the failure can occur before mutex_init(), so cleanup destroys an uninitialized mutex.
Initialize the mutex immediately after allocating the driver state, before creating any ancillary clients. This keeps every cleanup path matched with a completed mutex initialization.
A QEMU x86_64 test using an i2c-stub bus instantiated an ADV7280 client at address 0x21 and occupied its VPP ancillary address 0x42. This forced i2c_new_ancillary_device() to return -EBUSY. An instrumentation oracle observed an uninitialized mutex on the buggy kernel and an initialized mutex on the fixed kernel. The failure was deliberately injected to exercise the error path; no natural crash was observed.
--- drivers/media/i2c/adv7180.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +1 -1
@@ -1454,6 +1454,7 @@ static int adv7180_probe(struct i2c_client *client)if (state ==NULL )return -ENOMEM ; +mutex_init (&state->mutex); state->client = client; state->field =V4L2_FIELD_ALTERNATE ; state->chip_info =i2c_get_match_data (client);
@@ -1497,7 +1498,6 @@ static int adv7180_probe(struct i2c_client *client) } state->irq = client->irq; -mutex_init (&state->mutex); state->curr_norm =V4L2_STD_NTSC ; state->input =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 266/1257 media: au0828: Fix media device leak in au0828_usb_probe()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 7b7a69c91c0537d48150942d9707614a4fdd3766 ]
au0828_media_device_init() takes a reference to a media device with media_device_usb_allocate(). When au0828_v4l2_device_register() fails right after, the error path only unregisters the entities and frees au0828_dev, so that reference is never released.
Release it with media_device_delete() on that path.
--- drivers/media/usb/au0828/au0828-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/usb/au0828/au0828-core.c +4 -0
@@ -697,6 +697,10 @@ static int au0828_usb_probe(struct usb_interface *interface, retval =au0828_v4l2_device_register (interface, dev);if (retval) {au0828_usb_v4l2_media_release (dev); +#ifdef CONFIG_MEDIA_CONTROLLER +media_device_delete (dev->media_dev,KBUILD_MODNAME , +THIS_MODULE ); +#endif mutex_unlock (&dev->lock);kfree (dev);return retval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 267/1257 media: vpif_capture: Fix i2c adapter reference leak in vpif_probe()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b00fbdad64d4ea7d594bc67988c1722fe5b3be50 ]
vpif_probe() takes a reference to the i2c adapter with i2c_get_adapter() and passes it to v4l2_i2c_new_subdev_board(), which does not consume it, but the reference is never released, so it is leaked both when the probe succeeds and when it fails after the adapter has been acquired.
Release the reference with i2c_put_adapter() on the success path and in the probe_subdev_out cleanup, and initialise i2c_adap so that the cleanup is a no-op when the adapter was never acquired.
--- drivers/media/platform/ti/davinci/vpif_capture.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/ti/davinci/vpif_capture.c +4 -1
@@ -1602,7 +1602,7 @@ vpif_capture_get_pdata(struct platform_device *pdev,static int vpif_probe (struct platform_device *pdev) {struct vpif_subdev_info *subdevdata; -struct i2c_adapter *i2c_adap; +struct i2c_adapter *i2c_adap =NULL ;int subdev_count;int res_idx =0 ;int i, err;
@@ -1692,9 +1692,12 @@ static int vpif_probe(struct platform_device *pdev) } } +i2c_put_adapter (i2c_adap); +return 0 ; probe_subdev_out: +i2c_put_adapter (i2c_adap);v4l2_async_nf_cleanup (&vpif_obj.notifier);/* free sub devices memory */ kfree (vpif_obj.sd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 268/1257 media: vpif_display: Fix i2c adapter reference leak in vpif_probe()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit f5863ea3f99265e5e297e3dcf0f47432fee2b8ac ]
vpif_probe() takes a reference to the i2c adapter with i2c_get_adapter() and passes it to v4l2_i2c_new_subdev_board(), which does not consume it, but the reference is never released, so it is leaked both when the probe succeeds and when it fails after the adapter has been acquired.
Release the reference with i2c_put_adapter() on the success path and in the probe_subdev_out cleanup.
--- drivers/media/platform/ti/davinci/vpif_display.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/ti/davinci/vpif_display.c +3 -0
@@ -1289,9 +1289,12 @@ static int vpif_probe(struct platform_device *pdev)if (err) goto probe_subdev_out; +i2c_put_adapter (i2c_adap); +return 0 ; probe_subdev_out: +i2c_put_adapter (i2c_adap);kfree (vpif_obj.sd); vpif_unregister:v4l2_device_unregister (&vpif_obj.v4l2_dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 269/1257 media: synopsys: hdmirx: fetch colordepth before calculating pixelclock
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Sinn <[email protected]>
[ Upstream commit e8554ac860356f1f4cd9bce454271dce1ed35fc1 ]
hdmirx_get_detected_timings() divides the TMDS clock by hdmirx_dev->color_depth, but nothing on its own path ever sets it. The only producer is hdmirx_get_colordepth(), reached solely from hdmirx_format_change() at the tail of hdmirx_wait_signal_lock().
VIDIOC_QUERY_DV_TIMINGS does not come through there. It only refuses to proceed while signal_not_lock() is true, and that reads the lock state straight out of the hardware, so it can already be false while the work ending in hdmirx_format_change() has yet to run. Query the timings in that window, on the first lock after a boot, and color_depth is still zero from devm_kzalloc().
The division does not fault. do_div() is plain C on 64 bit and arm64 compiles it to udiv, which returns zero for a zero divisor. What comes out is a pixelclock of zero, and a stitched output frame.
Read the colordepth where it is used instead.
--- .../platform/synopsys/hdmirx/snps_hdmirx.c | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-)
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c +36 -35
@@ -156,7 +156,6 @@ struct snps_hdmirx_dev {int num_clks;u32 edid_blocks_written;u32 cur_fmt_fourcc; -u32 color_depth;spinlock_t rst_lock;/* to lock register access */ u8 edid[EDID_NUM_BLOCKS_MAX *EDID_BLOCK_SIZE ]; };
@@ -380,6 +379,38 @@ static void hdmirx_toggle_polarity(struct snps_hdmirx_dev *hdmirx_dev) VPROC_HSYNC_POL_OVR_EN, 0); } +static u32 hdmirx_get_colordepth (struct snps_hdmirx_dev *hdmirx_dev) +{ +struct v4l2_device *v4l2_dev = &hdmirx_dev->v4l2_dev; +u32 val, color_depth_reg, color_depth; + + val =hdmirx_readl (hdmirx_dev,DMA_STATUS11 ); + color_depth_reg = (val &HDMIRX_COLOR_DEPTH_MASK ) >>3 ; + +switch (color_depth_reg) { +case 0x4 : + color_depth =24 ; +break ; +case 0x5 : + color_depth =30 ; +break ; +case 0x6 : + color_depth =36 ; +break ; +case 0x7 : + color_depth =48 ; +break ; +default : + color_depth =24 ; +break ; + } + +v4l2_dbg (1 , debug, v4l2_dev,"%s: color_depth: %d, reg_val:%d\n" , + __func__, color_depth, color_depth_reg); + +return color_depth; +} +/* * When querying DV timings during preview, if the DMA's timing is stable, * we retrieve the timings directly from the DMA. However, if the current
@@ -393,7 +424,7 @@ static int hdmirx_get_detected_timings(struct snps_hdmirx_dev *hdmirx_dev,struct v4l2_bt_timings *bt = &timings->bt;u32 val, tmdsqpclk_freq, pix_clk;unsigned int num_retries =0 ; -u32 field_type, deframer_st; +u32 field_type, deframer_st, color_depth;u64 tmp_data, tmds_clk;bool is_dvi_mode;int ret;
@@ -414,10 +445,11 @@ static int hdmirx_get_detected_timings(struct snps_hdmirx_dev *hdmirx_dev, deframer_st =hdmirx_readl (hdmirx_dev,DEFRAMER_STATUS ); is_dvi_mode = !(deframer_st &OPMODE_STS_MASK ); + color_depth =hdmirx_get_colordepth (hdmirx_dev); tmdsqpclk_freq =hdmirx_readl (hdmirx_dev,CMU_TMDSQPCLK_FREQ ); tmds_clk = tmdsqpclk_freq *4 *1000 ; tmp_data = tmds_clk *24 ; -do_div (tmp_data, hdmirx_dev->color_depth); +do_div (tmp_data, color_depth); pix_clk = tmp_data; bt->pixelclock = pix_clk;
@@ -429,7 +461,7 @@ static int hdmirx_get_detected_timings(struct snps_hdmirx_dev *hdmirx_dev,v4l2_dbg (2 , debug, v4l2_dev,"tmds_clk:%llu, pix_clk:%d\n" , tmds_clk, pix_clk);v4l2_dbg (1 , debug, v4l2_dev,"interlace:%d, fmt:%d, color:%d, mode:%s\n" , bt->interlaced, hdmirx_dev->pix_fmt, - hdmirx_dev->color_depth, + color_depth, is_dvi_mode ?"dvi" :"hdmi" );v4l2_dbg (2 , debug, v4l2_dev,"deframer_st:%#x\n" , deframer_st);
@@ -988,36 +1020,6 @@ static void hdmirx_controller_init(struct snps_hdmirx_dev *hdmirx_dev) VS_REMAPFILTER_EN_QST | VS_FILTER_ORDER_QST(0x3)); } -static void hdmirx_get_colordepth (struct snps_hdmirx_dev *hdmirx_dev) -{ -struct v4l2_device *v4l2_dev = &hdmirx_dev->v4l2_dev; -u32 val, color_depth_reg; - - val =hdmirx_readl (hdmirx_dev,DMA_STATUS11 ); - color_depth_reg = (val &HDMIRX_COLOR_DEPTH_MASK ) >>3 ; - -switch (color_depth_reg) { -case 0x4 : - hdmirx_dev->color_depth =24 ; -break ; -case 0x5 : - hdmirx_dev->color_depth =30 ; -break ; -case 0x6 : - hdmirx_dev->color_depth =36 ; -break ; -case 0x7 : - hdmirx_dev->color_depth =48 ; -break ; -default : - hdmirx_dev->color_depth =24 ; -break ; - } - -v4l2_dbg (1 , debug, v4l2_dev,"%s: color_depth: %d, reg_val:%d\n" , - __func__, hdmirx_dev->color_depth, color_depth_reg); -} -static void hdmirx_get_pix_fmt (struct snps_hdmirx_dev *hdmirx_dev) {struct v4l2_device *v4l2_dev = &hdmirx_dev->v4l2_dev;
@@ -1128,7 +1130,6 @@ static void hdmirx_format_change(struct snps_hdmirx_dev *hdmirx_dev) };hdmirx_get_pix_fmt (hdmirx_dev); -hdmirx_get_colordepth (hdmirx_dev);hdmirx_get_avi_infoframe (hdmirx_dev);v4l2_dbg (1 , debug, v4l2_dev,"%s: queue res_chg_event\n" , __func__);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 270/1257 media: i2c: ov5647: fix power cleanup on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 6e81cfc38548109021ab761b94ecdd01f8753154 ]
ov5647_remove() disables runtime PM without powering off the sensor if it is still runtime active. pm_runtime_disable() does not invoke the runtime suspend callback, so the sensor can remain powered on.
If the device is not already runtime suspended, call ov5647_power_off() and mark the runtime PM state as suspended.
This issue was found by manual code inspection.
--- drivers/media/i2c/ov5647.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/i2c/ov5647.c +4 -0
@@ -1271,6 +1271,10 @@ static void ov5647_remove(struct i2c_client *client)v4l2_ctrl_handler_free (&sensor->ctrls);v4l2_device_unregister_subdev (sd);pm_runtime_disable (&client->dev); +if (!pm_runtime_status_suspended (&client->dev)) { +ov5647_power_off (&client->dev); +pm_runtime_set_suspended (&client->dev); + } }static const struct dev_pm_ops ov5647_pm_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 271/1257 media: atmel-isi: release unregistered video device on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit c0a6d78dad3af1def80f04df82bfd70456ec406c ]
atmel_isi_probe() allocates the video device before registering the V4L2 async notifier. The video device is registered later from the notifier complete callback once the remote subdevice has been bound.
The remove path relies on the notifier unbind callback to unregister the video device. However, if the remote subdevice is never bound, or the complete callback fails before video_register_device() succeeds, the video device remains unregistered. In that case the unbind path does not release the object allocated by video_device_alloc(), and the remove path leaks it.
Only unregister the video device from the unbind callback when it has actually been registered, and clear the driver pointer afterwards. After unregistering and cleaning up the notifier, release the video device directly if the pointer is still present. This covers devices that were allocated but never registered while avoiding a second release of successfully registered devices.
This issue was found by manual code inspection.
--- drivers/media/platform/atmel/atmel-isi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/platform/atmel/atmel-isi.c +6 -1
@@ -1121,10 +1121,13 @@ static void isi_graph_notify_unbind(struct v4l2_async_notifier *notifier, {struct atmel_isi *isi =notifier_to_isi (notifier); +if (!video_is_registered (isi->vdev)) +return ; +dev_dbg (isi->dev,"Removing %s\n" ,video_device_node_name (isi->vdev)); -/* Checks internally if vdev have been init or not */ video_unregister_device (isi->vdev); + isi->vdev =NULL ; } static int isi_graph_notify_bound(struct v4l2_async_notifier *notifier,
@@ -1323,6 +1326,8 @@ static void atmel_isi_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);v4l2_async_nf_unregister (&isi->notifier);v4l2_async_nf_cleanup (&isi->notifier); +if (isi->vdev) +video_device_release (isi->vdev);v4l2_device_unregister (&isi->v4l2_dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 272/1257 ASoC: fsl_xcvr: free IRQ before canceling reset work
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 83701fdb2d8d644c547773791da48d6ecb3a5e1d ]
irq0_isr() schedules work_rst on a preamble error, and reset_rx_work() touches regmap. remove() cancels that work while the IRQ is still registered, so the handler can queue it again during teardown. The IRQ is also requested before INIT_WORK() and spin_lock_init(). Probe failure does not call remove(), so freeing the IRQ leaves queued work running, and an earlier interrupt schedules uninitialized work.
Initialize the lock and devm_work_autocancel() before the IRQ. Failed probe then frees the IRQ and cancels the work. Unbind frees the IRQ before cancel_work_sync() and pm_runtime_disable().
--- sound/soc/fsl/fsl_xcvr.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
sound/soc/fsl/fsl_xcvr.c +19 -7
@@ -3,6 +3,7 @@#include <linux/bitrev.h> #include <linux/clk.h> +#include <linux/devm-helpers.h> #include <linux/firmware.h> #include <linux/interrupt.h> #include <linux/module.h>
@@ -57,6 +58,7 @@ struct fsl_xcvr {struct snd_aes_iec958 tx_iec958;u8 cap_ds[FSL_XCVR_CAPDS_SIZE ];struct work_struct work_rst; +int irq;spinlock_t lock;/* Protect hw_reset and trigger */ struct snd_pcm_hw_constraint_list spdif_constr_rates;u32 spdif_constr_rates_list[SPDIF_NUM_RATES ];
@@ -1617,7 +1619,7 @@ static int fsl_xcvr_probe(struct platform_device *pdev)struct fsl_xcvr *xcvr;struct resource *rx_res, *tx_res;void __iomem *regs; -int ret, irq; +int ret; xcvr =devm_kzalloc (dev,sizeof (*xcvr),GFP_KERNEL );if (!xcvr)
@@ -1705,12 +1707,22 @@ static int fsl_xcvr_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (xcvr->reset),"failed to get XCVR reset control\n" ); +/* +* irq0_isr() schedules work_rst. Prepare the work and its lock +* before the IRQ, and register the cancel action first so a failed +* probe frees the IRQ and then cancels any queued work. +*/ +spin_lock_init (&xcvr->lock); + ret =devm_work_autocancel (dev, &xcvr->work_rst, reset_rx_work); +if (ret) +return ret; +/* get IRQs */ - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return irq; + xcvr->irq =platform_get_irq (pdev,0 ); +if (xcvr->irq <0 ) +return xcvr->irq; - ret =devm_request_irq (dev, irq, irq0_isr,0 , pdev->name, xcvr); + ret =devm_request_irq (dev, xcvr->irq, irq0_isr,0 , pdev->name, xcvr);if (ret)return dev_err_probe (dev, ret,"failed to claim IRQ0\n" );
@@ -1751,8 +1763,6 @@ static int fsl_xcvr_probe(struct platform_device *pdev) fsl_xcvr_comp.name); } -INIT_WORK (&xcvr->work_rst, reset_rx_work); -spin_lock_init (&xcvr->lock);return ret; }
@@ -1760,6 +1770,8 @@ static void fsl_xcvr_remove(struct platform_device *pdev) {struct fsl_xcvr *xcvr =dev_get_drvdata (&pdev->dev); +/* Free the IRQ first so irq0_isr() cannot requeue work_rst. */ +devm_free_irq (&pdev->dev, xcvr->irq, xcvr);cancel_work_sync (&xcvr->work_rst);pm_runtime_disable (&pdev->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 273/1257 memory: stm32_omm: fix child clock leak on set_amcr() error path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Diego Fernando Mancera Gomez <[email protected]>
[ Upstream commit a22355280361d2a376a2020059a2bae11e6cea10 ]
When the mux is enabled, stm32_omm_configure() enables the two OSPI child clocks via stm32_omm_toggle_child_clock(dev, true); they are meant to stay enabled for the device's lifetime and are disabled again in stm32_omm_remove() and on the devm_of_platform_populate() error path.
However, if the subsequent stm32_omm_set_amcr() call fails, the function jumps to the "error:" label which only calls pm_runtime_put_sync_suspend() before returning, leaving the two child clocks enabled. As this happens during probe, the error is propagated and .remove() is never called, so the clock enable references are leaked. devm_clk_bulk_get() only releases the clock handles on unwind, it does not undo clk_prepare_enable().
Disable the child clocks on the set_amcr() error path, mirroring the cleanup already done on the devm_of_platform_populate() failure path.
--- drivers/memory/stm32_omm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/memory/stm32_omm.c +2 -0
@@ -274,6 +274,8 @@ static int stm32_omm_configure(struct device *dev)writel_relaxed (omm->cr, omm->io_base +OMM_CR ); ret =stm32_omm_set_amcr (dev, true); +if (ret && (mux &CR_MUXEN )) +stm32_omm_toggle_child_clock (dev, false); error:pm_runtime_put_sync_suspend (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 274/1257 arm64: dts: freescale: imx8mm-verdin-ivy: fix DIGI_1/DIGI_2 gpio-line-names
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Dolcini <[email protected]>
[ Upstream commit 28cec01a2be2cf1e20aabd435f250f665ce24c8e ]
gpio3's gpio-line-names names the two Ivy digital inputs "DIG_1" and "DIG_2", while the official Ivy Carrier Board datasheet (Section 2.10, Table 12) names them DIGI_1 and DIGI_2, matching the k3-am62-verdin-ivy.dtsi variant for the same carrier board pins.
GPIO line names are meant to be stable across the whole Verdin family and its carrier boards, so userspace GPIO tooling that looks up a line by name works the same regardless of which Verdin SoM is fitted on Ivy.
--- arch/arm64/boot/dts/freescale/imx8mm-verdin-ivy.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/freescale/imx8mm-verdin-ivy.dtsi +2 -2
@@ -270,8 +270,8 @@ &gpio3 { "", "", "", - "DIG_1", /* SODIMM 56 */ - "DIG_2", /* SODIMM 58 */ + "DIGI_1", /* SODIMM 56 */ + "DIGI_2", /* SODIMM 58 */ "REL1", /* SODIMM 60 */ "REL2", /* SODIMM 62 */ "", /* 10 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 275/1257 arm64: dts: freescale: imx8mp-verdin-ivy: fix DIGI_1/DIGI_2 gpio-line-names
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Dolcini <[email protected]>
[ Upstream commit cb45264c27fad31f7c58fbb1a5c2f7ec16018dae ]
gpio3's gpio-line-names names the two Ivy digital inputs "DIG_1" and "DIG_2", while the official Ivy Carrier Board datasheet (Section 2.10, Table 12) names them DIGI_1 and DIGI_2, matching the k3-am62-verdin-ivy.dtsi variant for the same carrier board pins.
GPIO line names are meant to be stable across the whole Verdin family and its carrier boards, so userspace GPIO tooling that looks up a line by name works the same regardless of which Verdin SoM is fitted on Ivy.
--- arch/arm64/boot/dts/freescale/imx8mp-verdin-ivy.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/freescale/imx8mp-verdin-ivy.dtsi +2 -2
@@ -333,8 +333,8 @@ &gpio3 { "", "", "", - "DIG_1", /* SODIMM 56 */ - "DIG_2", /* SODIMM 58 */ + "DIGI_1", /* SODIMM 56 */ + "DIGI_2", /* SODIMM 58 */ "REL1", /* SODIMM 60 */ "REL2", /* SODIMM 62 */ "", /* 10 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 276/1257 arm64: dts: freescale: imx95-aquila: fix gpio-line-names padding
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Dolcini <[email protected]>
[ Upstream commit 66a5b2bf9d217668ae683eecfaba38bcd61cfe94 ]
som_gpio_expander_1's gpio-line-names use "AQUILA_C1".."AQUILA_C4" instead of the zero-padded "AQUILA_C01".."AQUILA_C04" used by every other Cxx entry in this file and by k3-am69-aquila.dtsi, a different board implementing the same Aquila Family Specification. The zero-padded form is the official pin naming per the Aquila Family Specification and the Aquila iMX95 module datasheet.
GPIO line names are meant to be stable across the whole Aquila family, so userspace GPIO tooling that looks up a line by name works the same on any Aquila SoM.
--- arch/arm64/boot/dts/freescale/imx95-aquila.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/freescale/imx95-aquila.dtsi +4 -4
@@ -406,10 +406,10 @@ som_gpio_expander_1: gpio@21 { #gpio-cells = <2>; gpio-controller; gpio-line-names = - "AQUILA_C1", /* 0 */ - "AQUILA_C2", - "AQUILA_C3", - "AQUILA_C4", + "AQUILA_C01", /* 0 */ + "AQUILA_C02", + "AQUILA_C03", + "AQUILA_C04", "AQUILA_C36", "AQUILA_B74", "AQUILA_B75",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 277/1257 arm64: dts: freescale: imx8mp-toradex-smarc: fix SMARC_SLEEP# gpio-line-names typo
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Dolcini <[email protected]>
[ Upstream commit 90bc5a53c7f0733ec37a5c041b4e1aefa3d8d965 ]
gpio3's gpio-line-names has "SLEEP#" instead of "SMARC_SLEEP#" for the SMARC SLEEP# connector signal, while the gpio-keys node driven by the very same GPIO line already labels it "SMARC_SLEEP#", and the imx95 Toradex SMARC variant names the equivalent line "SMARC_SLEEP#" too.
GPIO line names are meant to be stable across the whole Toradex SMARC family, using the official SMARC-connector signal names from the SMARC specification and the SoM datasheet's pin assignment table, so userspace GPIO tooling that looks up a line by name works the same on any Toradex SMARC board.
--- arch/arm64/boot/dts/freescale/imx8mp-toradex-smarc.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8mp-toradex-smarc.dtsi +1 -1
@@ -323,7 +323,7 @@ &gpio3 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_lvds_dsi_sel>; gpio-line-names = "ETH_0_INT#", /* 0 */ - "SLEEP#", + "SMARC_SLEEP#", "", "", "",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 278/1257 arm64: dts: freescale: imx8mp-verdin-yavia: fix external GPIOs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Dolcini <[email protected]>
[ Upstream commit f377ac5999a5d045168ddd25d204691c6653c06a ]
pinctrl_gpios_ext_yavia (SODIMM 64/66) is defined but never applied to gpio3, so those pins stay at their NAND reset function instead of GPIO.
Fix SODIMM 64 to the correct pad, MX8MP_IOMUXC_NAND_READY_B (GPIO3_IO16).
--- arch/arm64/boot/dts/freescale/imx8mp-verdin-yavia.dtsi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8mp-verdin-yavia.dtsi +6 -1
@@ -117,6 +117,11 @@ &flexcan1 { status = "okay"; }; +&gpio3 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_gpios_ext_yavia>; +}; + &gpio4 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_ctrl_sleep_moci>;
@@ -266,7 +271,7 @@ MX8MP_IOMUXC_NAND_DATA03__GPIO3_IO09 0x106 /* SODIMM 62 */ pinctrl_gpios_ext_yavia: gpiosextyaviagrp { fsl,pins = < - MX8MP_IOMUXC_NAND_CE1_B__GPIO3_IO02 0x106 /* SODIMM 64 */ + MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO16 0x106 /* SODIMM 64 */ MX8MP_IOMUXC_NAND_DQS__GPIO3_IO14 0x106 /* SODIMM 66 */ >; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 279/1257 arm64: dts: freescale: imx95-toradex-smarc: enable Wi-Fi SD interface
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Dolcini <[email protected]>
[ Upstream commit b91cb164517d6cfbccd8bedad11827d8ea3bcb97 ]
Enable usdhc3, used for the on-module u-blox MAYA-W260 Wi-Fi/BT module, it was left disabled by mistake in the initial commit.
--- arch/arm64/boot/dts/freescale/imx95-toradex-smarc.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/freescale/imx95-toradex-smarc.dtsi +1 -0
@@ -839,6 +839,7 @@ &usdhc3 { keep-power-in-suspend; non-removable; vmmc-supply = <®_wifi_en>; + status = "okay"; }; &scmi_bbm {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 280/1257 clk: qcom: gcc-ipq5018: mark gpll0_main clock as critical
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit 33f9cb56cc28d002511e471be74f8ff241984178 ]
On IPQ5018, the APCS core clock feeds the CPUs. It can use different clocks as its parent, but during system boot it utilizes GPLL0.
Under some cicumstances, the 'gpll0_main' clock is getting disabled during kernel start which results in a system hang then the hardware watchdog restarts the board after a while.
This can happen when a driver gets a clock in its probe function, then releases it either directly or by devres cleanup on probe failure.
For example, since v6.18 the kernel often fails to boot on the TP-Link Archer AX55 v1 board by using the in-tree dts. In the failing configuration, the 'ipq-cmn-pll' driver is built into the kernel and the problem is caused by the pm_runtim_put() call in the ipq_cmn_pll_clk_probe() function. Due to this call, runtime pm disables the 'gcc_cmn_blk_ahb_clk' clock asynchronously which results in disabling 'gpll0_main' as well.
Mark the clock as critical in order to avoid such hangs.
--- drivers/clk/qcom/gcc-ipq5018.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/clk/qcom/gcc-ipq5018.c +9 -0
@@ -68,6 +68,15 @@ static struct clk_alpha_pll gpll0_main = { .parent_data = gcc_xo_data, .num_parents = ARRAY_SIZE(gcc_xo_data), .ops = &clk_alpha_pll_stromer_ops, +/* +* During system boot, this PLL feeds the CPUs. +* Mark it as critical to ensure that CCF does +* not disable it, even if there are no active +* consumers. This is needed to avoid a system +* hang caused by turning off the clock driving +* the CPUs. +*/ + .flags = CLK_IS_CRITICAL, }, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 281/1257 drm/panel: ebbg-ft8719: Set prepare_prev_first
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Casey Connolly <[email protected]>
[ Upstream commit 4eeeac9d7c3600a6cae75b2a7bc9c5b67530923c ]
This corrects the host initialisation sequence so that we can send DSI/DCS commands in prepare().
--- drivers/gpu/drm/panel/panel-ebbg-ft8719.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/panel/panel-ebbg-ft8719.c +2 -0
@@ -198,6 +198,8 @@ static int ebbg_ft8719_probe(struct mipi_dsi_device *dsi) dsi->mode_flags =MIPI_DSI_MODE_VIDEO |MIPI_DSI_MODE_VIDEO_BURST |MIPI_DSI_CLOCK_NON_CONTINUOUS ; + ctx->panel.prepare_prev_first = true; + ret =drm_panel_of_backlight (&ctx->panel);if (ret)return dev_err_probe (dev, ret,"Failed to get backlight\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 282/1257 mfd: da903x: Cancel IRQ work during teardown
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit fd2258999ecdc7164ef0cda2d4102e4558a5660f ]
The IRQ handler disables the IRQ and schedules irq_work. Releasing the IRQ does not drain that work, which can continue to use the devm-allocated chip and notifier state.
Manage both IRQ-work cancellation and subdevice removal with devres. Register the subdevice-removal action before requesting the IRQ, then add the IRQ-work action after the request. This avoids leaving a live IRQ without work cancellation if action registration fails. Devres cleanup then disables the IRQ and drains the work before releasing the IRQ and removing child devices. Register both actions before creating the children so partial probe failures use the same ordering.
This issue was found by the author's in-house static analysis tool. The patch was reviewed by the author against the latest mainline tree.
--- drivers/mfd/da903x.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
drivers/mfd/da903x.c +25 -9
@@ -421,6 +421,14 @@ static irqreturn_t da903x_irq_handler(int irq, void *data)return IRQ_HANDLED ; } +static void da903x_cancel_irq_work (void *data) +{ +struct da903x_chip *chip = data; + +disable_irq (chip->client->irq); +cancel_work_sync (&chip->irq_work); +} +static const struct da903x_chip_ops da903x_ops[] = { [0 ] = { .init_chip = da9030_init_chip,
@@ -456,6 +464,13 @@ static int da903x_remove_subdevs(struct da903x_chip *chip)return device_for_each_child (chip->dev,NULL , __remove_subdev); } +static void da903x_remove_subdevs_action (void *data) +{ +struct da903x_chip *chip = data; + +da903x_remove_subdevs (chip); +} +static int da903x_add_subdevs (struct da903x_chip *chip,struct da903x_platform_data *pdata) {
@@ -484,7 +499,6 @@ static int da903x_add_subdevs(struct da903x_chip *chip,return 0 ; failed: -da903x_remove_subdevs (chip);return ret; }
@@ -520,6 +534,11 @@ static int da903x_probe(struct i2c_client *client) chip->ops->mask_events (chip, chip->events_mask); chip->ops->read_events (chip, &tmp); + ret =devm_add_action_or_reset (&client->dev, + da903x_remove_subdevs_action, chip); +if (ret) +return ret; + ret =devm_request_irq (&client->dev, client->irq, da903x_irq_handler,IRQF_TRIGGER_FALLING ,"da903x" , chip);
@@ -529,14 +548,12 @@ static int da903x_probe(struct i2c_client *client)return ret; } -return da903x_add_subdevs (chip, pdata); -} - -static void da903x_remove (struct i2c_client *client) -{ -struct da903x_chip *chip =i2c_get_clientdata (client); + ret =devm_add_action_or_reset (&client->dev, da903x_cancel_irq_work, + chip); +if (ret) +return ret; -da903x_remove_subdevs (chip); +return da903x_add_subdevs (chip, pdata); }static struct i2c_driver da903x_driver = {
@@ -544,7 +561,6 @@ static struct i2c_driver da903x_driver = { .name = "da903x", }, .probe = da903x_probe, - .remove = da903x_remove, .id_table = da903x_id_table, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 283/1257 mfd: Fix MAX77705 dependency on regmap
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit 2fdae2d590a0a5ad4cd60bf8e7a6ecba7265f268 ]
The max77705 uses devm_regmap_add_irq_chip(), so add REGMAP_IRQ and REGMAP_I2C to what the core driver selects in order to provide these APIs.
This fixes a build error:
drivers/mfd/max77705.o: in function `max77705_i2c_probe':
max77705.c:(.text+0x250): undefined reference to `devm_regmap_add_irq_chip'
--- drivers/mfd/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/Kconfig +2 -0
@@ -1006,6 +1006,8 @@ config MFD_MAX77705 depends on I2C select MFD_CORE select MFD_SIMPLE_MFD_I2C + select REGMAP_I2C + select REGMAP_IRQ help Say yes here to add support for Maxim Integrated MAX77705 PMIC. This is a Power Management IC with Charger, safe LDOs, Flash, Haptic
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 284/1257 mfd: wcd934x: set DMA mask on parent to silence "DMA mask not set"
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit b296be1dc008fe3a536341afae01f66bb302e67f ]
The wcd934x MFD parent (a slim_device) never initializes its dma_mask/coherent_dma_mask. When the DT-aware children pass through of_dma_configure() this triggers the "DMA mask not set" warning for each child.
--- drivers/mfd/wcd934x.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mfd/wcd934x.c +6 -0
@@ -2,6 +2,7 @@// Copyright (c) 2019, Linaro Limited #include <linux/clk.h> +#include <linux/dma-mapping.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h> #include <linux/kernel.h>
@@ -217,6 +218,11 @@ static int wcd934x_slim_probe(struct slim_device *sdev)struct gpio_desc *reset_gpio;int ret; + ret =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (32 )); +if (ret) +return dev_err_probe (dev, ret, +"Failed to set DMA mask\n" ); + ddata =devm_kzalloc (dev,sizeof (*ddata),GFP_KERNEL );if (!ddata)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 285/1257 mfd: wcd934x: Fix NULL pointer dereference on IRQ probe deferral
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit dcf0e640b553d33512fbcaedb909c32ba9636a64 ]
ddata->dev is only assigned at the end of wcd934x_slim_probe(), but the of_irq_get() error path has passed it to the error print since the driver was added, while it is still NULL.
This used to be harmless with dev_err(), which copes with a NULL device and was skipped on -EPROBE_DEFER. Since the switch to dev_err_probe(), a deferred IRQ reaches device_set_deferred_probe_reason() -> dev_driver_string(), which dereferences the NULL pointer and crashes during probe. Use dev, which is already valid at this point.
--- drivers/mfd/wcd934x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/wcd934x.c +1 -1
@@ -229,7 +229,7 @@ static int wcd934x_slim_probe(struct slim_device *sdev) ddata->irq =of_irq_get (np,0 );if (ddata->irq <0 ) -return dev_err_probe (ddata->dev, ddata->irq, +return dev_err_probe (dev, ddata->irq,"Failed to get IRQ\n" ); ddata->extclk =devm_clk_get (dev,"extclk" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 286/1257 mfd: twl-core: Unregister the auxiliary platform device on unbind
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 3c5c55d979ddcb0765ce531bc7ba173c87c8712a ]
twl_probe() registers a standalone platform device named "twl", but keeps its pointer only in a local variable. Probe errors unregister the device, while successful probe leaves no way for twl_remove() to release it. The platform device therefore remains registered after the I2C driver unbinds.
Register a managed action on the I2C device immediately after adding the platform device. This unregisters it on probe failure and driver unbind, and also handles failure to register the action itself. Remove the manual error-path unregister to avoid releasing the device twice.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/mfd/twl-core.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mfd/twl-core.c +15 -8
@@ -719,6 +719,11 @@ static const struct mfd_cell twl6032_cells[] = { { .name = "twl6032-clk" }, }; +static void twl_unregister_device (void *data) +{ +platform_device_unregister (data); +} +/* NOTE: This driver only handles a single twl4030/tps659x0 chip */ static int twl_probe (struct i2c_client *client)
@@ -754,17 +759,22 @@ twl_probe(struct i2c_client *client)return status; } + status =devm_add_action_or_reset (&client->dev, twl_unregister_device, + pdev); +if (status) +return status; +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; - goto free; + goto out; } twl_priv =devm_kzalloc (&client->dev,sizeof (struct twl_private ),GFP_KERNEL );if (!twl_priv) { status = -ENOMEM ; - goto free; + goto out; }if ((id->driver_data) &TWL6030_CLASS ) {
@@ -784,7 +794,7 @@ twl_probe(struct i2c_client *client) GFP_KERNEL);if (!twl_priv->twl_modules) { status = -ENOMEM ; - goto free; + goto out; }for (i =0 ; i < num_slaves; i++) {
@@ -880,7 +890,7 @@ twl_probe(struct i2c_client *client) status =devm_mfd_add_devices (&client->dev,PLATFORM_DEVID_NONE , cells, num_cells,NULL ,0 ,NULL );if (status <0 ) - goto free; + goto out;if (of_device_is_system_power_controller (node)) {if (!pm_power_off)
@@ -896,10 +906,7 @@ twl_probe(struct i2c_client *client) fail:if (status <0 )twl_remove (client); -free: -if (status <0 ) -platform_device_unregister (pdev); - +out:return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 287/1257 hwmon: (k10temp) Stop matching Hygon devices
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lin Wang <[email protected]>
[ Upstream commit 08e6615c909b2504a5862764f3a7fca00c7ab066 ]
k10temp matches the Hygon F3 device, but derives the node passed to amd_smn_read() from the F3 PCI slot using the AMD fixed-slot mapping (slot - 0x18). Hygon PCI slots do not encode DF node identity, and their SMN roots are grouped by socket.
The derived node number therefore cannot identify a valid Hygon SMN target or provide usable temperature monitoring. Removing the match does not disable a working monitoring path.
Remove the Hygon PCI match and Family 0x18 branch. Hygon temperature monitoring will use the Hygon node and SMN interfaces in a separate series.
--- Documentation/hwmon/k10temp.rst | 8 +++----- drivers/hwmon/k10temp.c | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-)
Documentation/hwmon/k10temp.rst +3 -5
@@ -28,8 +28,6 @@ Supported chips: * AMD Family 17h processors: "Zen", "Zen 2" -* AMD Family 18h processors: "Hygon Dhyana" - * AMD Family 19h processors: "Zen 3" Prefix: 'k10temp'
@@ -128,7 +126,7 @@ it. Models from 17h family report relative temperature, the driver aims to compensate and report the real temperature. -On Family 17h and Family 18h CPUs, additional temperature sensors may report -Core Complex Die (CCD) temperatures. Up to 8 such temperatures are reported -as temp{3..10}_input, labeled Tccd{1..8}. Actual support depends on the CPU +On Family 17h CPUs, additional temperature sensors may report Core Complex +Die (CCD) temperatures. Up to 8 such temperatures are reported as +temp{3..10}_input, labeled Tccd{1..8}. Actual support depends on the CPU variant.
drivers/hwmon/k10temp.c +2 -3
@@ -64,7 +64,7 @@ MODULE_PARM_DESC(force, "force loading on processors with erratum 319");#define F15H_M60H_HARDWARE_TEMP_CTRL_OFFSET 0xd8200c64#define F15H_M60H_REPORTED_TEMP_CTRL_OFFSET 0xd8200ca4 -/* Common for Zen CPU families (Family 17h and 18h and 19h and 1Ah) */ +/* Common for Zen CPU families (Family 17h, 19h and 1Ah) */ #define ZEN_REPORTED_TEMP_CTRL_BASE 0x00059800#define ZEN_CCD_TEMP (offset, x) (ZEN_REPORTED_TEMP_CTRL_BASE + \
@@ -475,7 +475,7 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) data->read_tempreg = read_tempreg_pci; } -if (boot_cpu_data.x86 ==0x17 || boot_cpu_data.x86 ==0x18 ) { +if (boot_cpu_data.x86 ==0x17 ) {switch (boot_cpu_data.x86_model) {case 0x1 :/* Zen */ case 0x8 :/* Zen+ */
@@ -583,7 +583,6 @@ static const struct pci_device_id k10temp_id_table[] = { { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_1AH_M60H_DF_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_1AH_M70H_DF_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_1AH_M90H_DF_F3) }, - { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) }, {} };MODULE_DEVICE_TABLE (pci, k10temp_id_table);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 288/1257 perf loongarch: Fix discarded const qualifier in _get_field()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
[ Upstream commit ed1293302f811fa709897d4a90ad78592938e4aa ]
When building perf on LoongArch, the following compilation errors occur:
CC arch/loongarch/util/header.oarch/loongarch/util/header.c: In function '_get_field':arch/loongarch/util/header.c:31:15: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
31 | line2 = strrchr(line, ' ');
| ^arch/loongarch/util/header.c:36:12: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
36 | nl = strrchr(line, '\n');
| ^
cc1: all warnings being treated as errors
Declare 'line2' and 'nl' as const char * to ensure type safety. In modern glibc versions, strrchr() returns a 'const char *' if the input string is const.
This is similar to commit 7378b6656aa4 ("perf riscv: Fix discarded const qualifier in _get_field()").
--- tools/perf/arch/loongarch/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/loongarch/util/header.c +1 -1
@@ -26,7 +26,7 @@static char *_get_field (const char *line) { -char *line2, *nl; +const char *line2, *nl; line2 =strrchr (line,' ' );if (!line2)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 289/1257 nilfs2: fix deadlock between nilfs_evict_inode() and find_inode()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit ff1227f70eead8704ecfec69259fb4c041f92cda ]
Syzbot reported a deadlock between nilfs_evict_inode(), executed via an asynchronous workqueue (kworker) as:
process_one_work()
process_scheduled_works()
nilfs_iput_work_func()
nilfs_dispose_list()
iput()
iput_final()
evict()
s_op->evict_inode()
nilfs_evict_inode()and find_inode(), called via
nilfs_mkdir()
nilfs_new_inode()
nilfs_insert_inode_locked()
insert_inode_locked4()
inode_insert5()
find_inode()When an inode is deleted (i_nlink == 0), nilfs_evict_inode() clears its ifile bitmap entry and then synchronously triggers the log writer via nilfs_transaction_commit() if IS_SYNC(inode) is true.
If a concurrent directory creation via nilfs_new_inode() attempts to allocate the same newly freed inode number, however, find_inode() called just before inserting it into the inode hash, blocks waiting for the old inode's evict() to complete.
Meanwhile, the synchronous log writer invoked from nilfs_evict_inode() tries to acquire a write lock on 'ns_segctor_sem' which is read locked by the caller of nilfs_new_inode() (in this case, nilfs_mkdir()), resulting in a deadlock.
The synchronous log writer invocation from nilfs_evict_inode() is a legacy artifact; it is no longer necessary because the call itself (triggered by iput()) is now handled asynchronously with a kworker if i_nlink == 0. It merely increases the risk of deadlock.
Fix this deadlock by removing the synchronous log writer trigger from nilfs_evict_inode().
--- fs/nilfs2/inode.c | 6 ------ 1 file changed, 6 deletions(-)
fs/nilfs2/inode.c +0 -6
@@ -895,13 +895,7 @@ void nilfs_evict_inode(struct inode *inode)nilfs_clear_inode (inode); -if (IS_SYNC (inode)) -nilfs_set_transaction_flag (NILFS_TI_SYNC );nilfs_transaction_commit (sb); -/* -* May construct a logical segment and may fail in sync mode. -* But delete_inode has no return value. -*/ } int nilfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 290/1257 kobject: fix out-of-bounds access in kobject_action_type()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiacheng Xu <[email protected]>
[ Upstream commit d516455c940555566642b975d1835c67f08136b3 ]
kobject_action_type() compares the input against each known action using strncmp() and then indexes the action string using count_first to check for an exact-length match.
An embedded NUL can make strncmp() return zero even when count_first exceeds the length of the action string. For example, the five-byte input "add\0X" makes the parser access kobject_actions[KOBJ_ADD][5], which is beyond the end of the "add" string.
Check the action string length with strlen() instead of indexing it with the input-derived offset. This rejects malformed action strings containing embedded NUL bytes with -EINVAL instead of invoking undefined behavior.
--- lib/kobject_uevent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kobject_uevent.c +1 -1
@@ -83,7 +83,7 @@ static int kobject_action_type(const char *buf, size_t count,for (action =0 ; action <ARRAY_SIZE (kobject_actions); action++) {if (strncmp (kobject_actions[action], buf, count_first) !=0 )continue ; -if (kobject_actions[action][count_first] !='\0' ) +if (strlen (kobject_actions[action]) != count_first)continue ;if (args) *args = args_start;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 291/1257 ASoC: Intel: atom: Fix platform device leak on probe failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit dcc36d766dc82bc57cd730915d484119befcfca8 ]
sst_acpi_probe() registers platform devices for the SST platform and machine board using platform_device_register_data(), but does not unregister them when later probe steps fail.
--- sound/soc/intel/atom/sst/sst_acpi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
sound/soc/intel/atom/sst/sst_acpi.c +13 -1
@@ -254,6 +254,11 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)return 0 ; } +static void sst_unregister_platform_device (void *data) +{ +platform_device_unregister (data); +} +static int sst_acpi_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -342,7 +347,10 @@ static int sst_acpi_probe(struct platform_device *pdev) pdata->platform);return PTR_ERR (plat_dev); } - + ret =devm_add_action_or_reset (dev, sst_unregister_platform_device, + plat_dev); +if (ret) +return ret;/* * Create platform device for sst machine driver, * pass machine info as pdata
@@ -355,6 +363,10 @@ static int sst_acpi_probe(struct platform_device *pdev)return PTR_ERR (mdev); } + ret =devm_add_action_or_reset (dev, sst_unregister_platform_device, + mdev); +if (ret) +return ret;/* Fill sst platform data */ ctx->pdata = pdata;strscpy (ctx->firmware_name, mach->fw_filename);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 292/1257 ASoC: rt712-sdca-dmic: fix drvdata type in the gain controls
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junjie Cao <[email protected]>
[ Upstream commit 0bc42544a4a06e8d76eb412d2b1414db910a311d ]
rt712_sdca_dmic_set_gain_get() and rt712_sdca_dmic_set_gain_put() take the component drvdata as struct rt712_sdca_priv, but this driver stores a struct rt712_sdca_dmic_priv.
regmap and mbq_regmap are at the same offsets in both structs, so the register accesses work. slave is not: rt712_sdca_priv has dmic_component in front of it, so its slave overlays rt712_sdca_dmic_priv's params, which this driver never writes. When regmap_write() fails in the put handler, dev_err() is called with &NULL->dev (RSI below):
rt712-sdca-dmic sdw:0:3:025d:1713:01: Defer on undeferrable control: 40800f13
BUG: kernel NULL pointer dereference, address: 0000000000000058 RIP: 0010:__dev_printk+0x10/0x70 RDX: ffffcdac45f83cd0 RSI: 0000000000000008 RDI: ffffffffa09cb5cb Call Trace: _dev_err+0x7f/0x99 rt712_sdca_dmic_set_gain_put.cold+0x20/0x25 [snd_soc_rt712_sdca_dmic] snd_ctl_elem_write+0x19a/0x1f0 [snd] snd_ctl_ioctl+0x658/0x8a0 [snd]
Seen on a Dell Precision 5690 running 7.2.5-200.fc44, with alsactl writing the control during boot. Compile-tested only.
--- sound/soc/codecs/rt712-sdca-dmic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/rt712-sdca-dmic.c +2 -2
@@ -246,7 +246,7 @@ static int rt712_sdca_dmic_set_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol); -struct rt712_sdca_priv *rt712 =snd_soc_component_get_drvdata (component); +struct rt712_sdca_dmic_priv *rt712 =snd_soc_component_get_drvdata (component);struct rt712_sdca_dmic_kctrl_priv *p = (struct rt712_sdca_dmic_kctrl_priv *)kcontrol->private_value;unsigned int regvalue, ctl, i;
@@ -277,7 +277,7 @@ static int rt712_sdca_dmic_set_gain_put(struct snd_kcontrol *kcontrol,struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);struct rt712_sdca_dmic_kctrl_priv *p = (struct rt712_sdca_dmic_kctrl_priv *)kcontrol->private_value; -struct rt712_sdca_priv *rt712 =snd_soc_component_get_drvdata (component); +struct rt712_sdca_dmic_priv *rt712 =snd_soc_component_get_drvdata (component);unsigned int gain_val[4 ];unsigned int i, adc_vol_flag =0 , changed =0 ;unsigned int regvalue[4 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 293/1257 clk: mvebu: ap-cpu-clk: Assign .num before accessing .hws
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
[ Upstream commit b4243850393f2f24e21b9f4b2c56233e60c904b4 ]
Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' with __counted_by, which informs the bounds sanitizer (UBSAN_BOUNDS) about the number of elements in .hws[], so that it can warn when .hws[] is accessed out of bounds. As noted in that change, the __counted_by member must be initialized with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialization because the number of elements is zero. This occurs in ap_cpu_clock_probe(), which reads .hws[] to skip clusters that have already been set up and writes it inside the CPU node loop, but only assigns .num after the loop. With CONFIG_UBSAN_BOUNDS and a compiler that implements __counted_by (GCC 15.1+ or Clang 20.1+), this triggers an array-index-out-of-bounds report during probe of the AP806 and AP807 CPU clocks, and with CONFIG_UBSAN_TRAP the first access traps.
Initialize .num with nclusters, the number of elements .hws[] was allocated with, right after the allocation. For the in-tree AP806 and AP807 device trees, which list the CPU nodes in ascending order, this is exactly the value the old assignment produced. It is also the correct value for any other node order, since of_clk_hw_onecell_get() rejects indices at or beyond .num.
--- drivers/clk/mvebu/ap-cpu-clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/mvebu/ap-cpu-clk.c +2 -2
@@ -284,6 +284,8 @@ static int ap_cpu_clock_probe(struct platform_device *pdev)if (!ap_cpu_data)return -ENOMEM ; + ap_cpu_data->num = nclusters; +for_each_of_cpu_node (dn) {char *clk_name ="cpu-cluster-0" ;struct clk_init_data init;
@@ -333,8 +335,6 @@ static int ap_cpu_clock_probe(struct platform_device *pdev) ap_cpu_data->hws[cluster_index] = &ap_cpu_clk[cluster_index].hw; } - ap_cpu_data->num = cluster_index +1 ; - ret =of_clk_add_hw_provider (np, of_clk_hw_onecell_get, ap_cpu_data);if (ret)dev_err (dev,"failed to register OF clock provider\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 294/1257 KVM: arm64: ptdump: Check the page tables arent freed when accessing
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei-Lin Chang <[email protected]>
[ Upstream commit 7d7199bdf77a3a6ed74d0037133f435a7febe97c ]
An open debugfs file keeps the KVM structure alive, but does not prevent mmu notifier release from freeing the stage-2 page tables when the VMM’s address space is torn down. Therefore page tables belonging to the mmus could have been freed when a thread opens or reads the ptdump files. Take the mmu_lock and check mmu->pgt is still alive before accessing the page tables.
Also for the ipa_range file and stage2_levels file, switch from keeping the pointer to the page tables to keeping the pointer to the mmu.
--- arch/arm64/kvm/ptdump.c | 43 +++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-)
arch/arm64/kvm/ptdump.c +33 -10
@@ -115,15 +115,28 @@ static int kvm_ptdump_build_levels(struct ptdump_pg_level *level, u32 start_lvl)static struct kvm_ptdump_guest_state *kvm_ptdump_parser_create (struct kvm_s2_mmu *mmu) { +struct kvm *kvm =kvm_s2_mmu_to_kvm (mmu);struct kvm_ptdump_guest_state *st; -struct kvm_pgtable *pgtable = mmu->pgt; +s8 start_level;int ret; +/* +* We only need the pgt start level to initialize the ptdump, get it +* while holding the mmu_lock. It's fine if the pgt gets freed +* afterwards, we'll check again when doing the actual dump. +*/ + scoped_guard(read_lock, &kvm->mmu_lock) { +if (mmu->pgt) + start_level = mmu->pgt->start_level; +else +return ERR_PTR (-ENOENT ); + } + st = kzalloc_obj(struct kvm_ptdump_guest_state, GFP_KERNEL_ACCOUNT);if (!st)return ERR_PTR (-ENOMEM ); - ret =kvm_ptdump_build_levels (&st->level[0 ], pgtable->start_level); + ret =kvm_ptdump_build_levels (&st->level[0 ], start_level);if (ret) {kfree (st);return ERR_PTR (ret);
@@ -149,6 +162,9 @@ static int kvm_ptdump_guest_show(struct seq_file *m, void *unused) };guard (write_lock)(&kvm->mmu_lock); +if (!mmu->pgt) +return 0 ; + st->parser_state = (struct ptdump_pg_state ) { .marker = &st->ipa_marker[0 ], .end_address =BIT (mmu->pgt->ia_bits),
@@ -211,17 +227,27 @@ static const struct file_operations kvm_ptdump_guest_fops = {static int kvm_pgtable_range_show (struct seq_file *m,void *unused) { -struct kvm_pgtable *pgtable = m->private; +struct kvm_s2_mmu *mmu = m->private; +struct kvm *kvm =kvm_s2_mmu_to_kvm (mmu); + +guard (read_lock)(&kvm->mmu_lock); + +if (mmu->pgt) +seq_printf (m,"%2u\n" , mmu->pgt->ia_bits); -seq_printf (m,"%2u\n" , pgtable->ia_bits);return 0 ; }static int kvm_pgtable_levels_show (struct seq_file *m,void *unused) { -struct kvm_pgtable *pgtable = m->private; +struct kvm_s2_mmu *mmu = m->private; +struct kvm *kvm =kvm_s2_mmu_to_kvm (mmu); + +guard (read_lock)(&kvm->mmu_lock); + +if (mmu->pgt) +seq_printf (m,"%1d\n" ,KVM_PGTABLE_MAX_LEVELS - mmu->pgt->start_level); -seq_printf (m,"%1d\n" ,KVM_PGTABLE_MAX_LEVELS - pgtable->start_level);return 0 ; }
@@ -230,15 +256,12 @@ static int kvm_pgtable_debugfs_open(struct inode *m, struct file *file, {struct kvm_s2_mmu *mmu = m->i_private;struct kvm *kvm =kvm_s2_mmu_to_kvm (mmu); -struct kvm_pgtable *pgtable;int ret;if (!kvm_get_kvm_safe (kvm))return -ENOENT ; - pgtable = mmu->pgt; - - ret =single_open (file, show, pgtable); + ret =single_open (file, show, mmu);if (ret <0 )kvm_put_kvm (kvm);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 295/1257 KVM: arm64: ptdump: Fix shadow ptdump sleep-in-atomic-context problem
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei-Lin Chang <[email protected]>
[ Upstream commit b1cc219eb21ab5f31fe4caa32be8057159e42db5 ]
Previously we exposed shadow page tables by creating a debugfs ptdump file whenever a nested mmu instance gets bound to a new context, and deleting the debugfs file whose context was getting unbound.
This turned out to be buggy, as the instance<->context binding process is done with the mmu_lock held, and debugfs creation/deletion can sleep.
Change the approach and create a shadow ptdump file for each nested mmu instead during kvm_vcpu_init_nested(), in a sleepable context. The files will be named nested_mmu<index>, and reading it will return the nested context's VTTBR, VTCR, and s2 enabled or not before dumping the shadow page tables, given the nested mmu is valid.
--- arch/arm64/include/asm/kvm_mmu.h | 6 ++---- arch/arm64/kvm/nested.c | 9 ++++----- arch/arm64/kvm/ptdump.c | 32 +++++++++++++++----------------- 3 files changed, 21 insertions(+), 26 deletions(-)
arch/arm64/include/asm/kvm_mmu.h +2 -4
@@ -392,12 +392,10 @@ static inline bool kvm_supports_cacheable_pfnmap(void)#ifdef CONFIG_PTDUMP_STAGE2_DEBUGFS void kvm_s2_ptdump_create_debugfs (struct kvm *kvm); -void kvm_nested_s2_ptdump_create_debugfs (struct kvm_s2_mmu *mmu); -void kvm_nested_s2_ptdump_remove_debugfs (struct kvm_s2_mmu *mmu); +void kvm_nested_s2_ptdump_create_debugfs (struct kvm_s2_mmu *mmu,int idx);#else static inline void kvm_s2_ptdump_create_debugfs (struct kvm *kvm) {} -static inline void kvm_nested_s2_ptdump_create_debugfs (struct kvm_s2_mmu *mmu) {} -static inline void kvm_nested_s2_ptdump_remove_debugfs (struct kvm_s2_mmu *mmu) {} +static inline void kvm_nested_s2_ptdump_create_debugfs (struct kvm_s2_mmu *mmu,int idx) {}#endif /* CONFIG_PTDUMP_STAGE2_DEBUGFS */ #endif /* __ASSEMBLER__ */
arch/arm64/kvm/nested.c +4 -5
@@ -124,6 +124,9 @@ int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu)return ret; } +for (i =0 ; i <S2_MMU_PER_VCPU ; i++) +kvm_nested_s2_ptdump_create_debugfs (&tmp[i], i + kvm->arch.nested_mmus_size); +guard (write_lock)(&kvm->mmu_lock);for (i =0 ; i <S2_MMU_PER_VCPU ; i++)
@@ -837,10 +840,8 @@ static struct kvm_s2_mmu *get_s2_mmu_nested(struct kvm_vcpu *vcpu) kvm->arch.nested_mmus_next = (i +1 ) % kvm->arch.nested_mmus_size;/* Make sure we don't forget to do the laundry */ -if (kvm_s2_mmu_valid (s2_mmu)) { -kvm_nested_s2_ptdump_remove_debugfs (s2_mmu); +if (kvm_s2_mmu_valid (s2_mmu)) s2_mmu->pending_unmap = true; - }/* * The virtual VMID (modulo CnP) will be used as a key when matching
@@ -854,8 +855,6 @@ static struct kvm_s2_mmu *get_s2_mmu_nested(struct kvm_vcpu *vcpu) s2_mmu->tlb_vtcr =vcpu_read_sys_reg (vcpu,VTCR_EL2 ); s2_mmu->nested_stage2_enabled =vcpu_read_sys_reg (vcpu,HCR_EL2 ) &HCR_VM ; -kvm_nested_s2_ptdump_create_debugfs (s2_mmu); - out:atomic_inc (&s2_mmu->refcnt);
arch/arm64/kvm/ptdump.c +15 -17
@@ -17,7 +17,7 @@#define MARKERS_LEN 2#define KVM_PGTABLE_MAX_LEVELS (KVM_PGTABLE_LAST_LEVEL + 1) -#define S2FNAMESZ sizeof("0x0123456789abcdef-0x0123456789abcdef-s2-disabled") +#define S2FNAMESZ sizeof("nested_mmu0000")struct kvm_ptdump_guest_state {struct kvm_s2_mmu *mmu;
@@ -173,6 +173,15 @@ static int kvm_ptdump_guest_show(struct seq_file *m, void *unused) .seq = m, }; +if (kvm_is_nested_s2_mmu (kvm, mmu)) { +if (kvm_s2_mmu_valid (mmu)) +seq_printf (m,"VTCR: 0x%016llx VTTBR: 0x%016llx s2: %s\n" , + mmu->tlb_vtcr, mmu->tlb_vttbr, + mmu->nested_stage2_enabled ?"enabled" :"disabled" ); +else +return 0 ; + } + ret =kvm_pgtable_walk (mmu->pgt,0 ,BIT (mmu->pgt->ia_bits), &walker);if (ret)return ret;
@@ -299,26 +308,15 @@ static const struct file_operations kvm_pgtable_levels_fops = { .release = kvm_pgtable_debugfs_close, }; -void kvm_nested_s2_ptdump_create_debugfs (struct kvm_s2_mmu *mmu) +void kvm_nested_s2_ptdump_create_debugfs (struct kvm_s2_mmu *mmu,int idx) { -struct dentry *dent;char file_name[S2FNAMESZ ]; -snprintf (file_name,sizeof (file_name),"0x%016llx-0x%016llx-s2-%sabled" , - mmu->tlb_vttbr, - mmu->tlb_vtcr, - mmu->nested_stage2_enabled ?"en" :"dis" ); - - dent =debugfs_create_file (file_name,0400 , - mmu->arch->debugfs_nv_dentry, mmu, - &kvm_ptdump_guest_fops); +snprintf (file_name,sizeof (file_name),"nested_mmu%d" , idx); - mmu->shadow_pt_debugfs_dentry = dent; -} - -void kvm_nested_s2_ptdump_remove_debugfs (struct kvm_s2_mmu *mmu) -{ -debugfs_remove (mmu->shadow_pt_debugfs_dentry); +debugfs_create_file (file_name,0400 , + mmu->arch->debugfs_nv_dentry, mmu, + &kvm_ptdump_guest_fops); }void kvm_s2_ptdump_create_debugfs (struct kvm *kvm)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 296/1257 regulator: core: Fix coupled regulators reference leak on removal
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b9205f0837ca91a0bbe6aa9002207656840c1406 ]
of_parse_coupled_regulator() returns the coupled regulator with its device reference incremented and regulator_resolve_coupling() stores it in coupling_desc.coupled_rdevs[]. regulator_remove_coupling() clears those pointers without dropping the references, so they are leaked when the couple is torn down.
Release the reference of each coupled regulator while removing the coupling.
--- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/core.c +2 -0
@@ -5909,6 +5909,8 @@ static void regulator_remove_coupling(struct regulator_dev *rdev) c_desc->coupled_rdevs[i] =NULL ; c_desc->n_resolved--; + +put_device (&c_rdev->dev); }if (coupler && coupler->detach_regulator) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 297/1257 hwmon: (lm95245) Fix negative temperature conversion
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridham Khurana <[email protected]>
[ Upstream commit f58c16056f8585ebafb0f1f5d90c23085443a4b9 ]
temp_from_reg_signed() uses only the high byte when the sign bit is set and drops the fractional bits in the low byte. Writing -500 to temp2_offset stores 0xff80 (-0.5 degrees C) in the offset registers, but reading temp2_offset back returns -1000.
Negative temp1_input and temp2_input values are rounded down to the next whole degree the same way. The chip reports -0.125 degrees C as 0xffe0, which the driver returns as -1000.
Treat the register pair as a single 16-bit two's complement value.
--- drivers/hwmon/lm95245.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwmon/lm95245.c +3 -3
@@ -96,9 +96,9 @@ static int temp_from_reg_unsigned(u8 val_h, u8 val_l)static int temp_from_reg_signed (u8 val_h,u8 val_l) { -if (val_h &0x80 ) -return (val_h -0x100 ) *1000 ; -return temp_from_reg_unsigned (val_h, val_l); +s16 val_hl = (val_h <<8 ) | val_l; + +return val_hl *1000 /256 ; }static int lm95245_read_conversion_rate (struct lm95245_data *data)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 298/1257 hwmon: (lm70) Fix rounding of negative temperatures
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridham Khurana <[email protected]>
[ Upstream commit eddb0aaacce4baa9d8176eb2f4bd9e99e867f8fc ]
temp1_input_show() drops the low bits of the temperature register by dividing the raw value (raw / 32 on the LM70). These bits are not part of the temperature: the LM70, LM71, LM74 and TMP122/TMP124 always return some of them as 1, and the TMP125 fills them with copies of the temperature LSB. Division rounds toward zero, so a negative temperature with any of these bits set is reported one LSB too high.
For example, the TMP122 returns 0xffff for -0.0625 degrees C, which the driver reports as 0. The LM70 returns 0xf39f for -25 degrees C, which the driver reports as -24750.
Use an arithmetic right shift instead, which drops the low bits and rounds down.
--- drivers/hwmon/lm70.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/lm70.c +4 -4
@@ -96,21 +96,21 @@ static ssize_t temp1_input_show(struct device *dev,*/ switch (p_lm70->chip) {case LM70_CHIP_LM70 : - val = ((int )raw /32 ) *250 ; + val = ((int )raw >>5 ) *250 ;break ;case LM70_CHIP_TMP121 :case LM70_CHIP_TMP122 :case LM70_CHIP_LM74 : - val = ((int )raw /8 ) *625 /10 ; + val = ((int )raw >>3 ) *625 /10 ;break ;case LM70_CHIP_LM71 : - val = ((int )raw /4 ) *3125 /100 ; + val = ((int )raw >>2 ) *3125 /100 ;break ;case LM70_CHIP_TMP125 : - val = (sign_extend32 (raw,14 ) /32 ) *250 ; + val = (sign_extend32 (raw,14 ) >>5 ) *250 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/1257 fuse: dont shorten the folio descriptor at LLONG_MAX
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joanne Koong <[email protected]>
[ Upstream commit 4c72635f913850512d5fa74bf3eb7db3670398cf ]
fuse_send_readpages() and fuse_do_readfolio() both decrement the folio descriptor length when handling the overflow case where a read would exceed LLONG_MAX after incrementing the file position by the number of bytes that need to be read in.
Shortening it is unnecessary (and for the virtio-fs paths, a bug), and with fuse using iomap for handling reads, shortening it is buggy.
For fuse_send_readpages(), ap->descs[] is also what fuse_readpages_end() reports back to iomap_finish_folio_read(). iomap accounted the full length when the range was submitted, so the lengths reported on completion have to add up to what was submitted. Reporting one byte less leaves ifs->read_bytes_pending nonzero, folio_end_read() is never called, and the folio stays locked.
This is currently reachable on fuseblk mounts configured with block sizes smaller than the page size.
Fix this by leaving the descriptor length untouched. The reply will then be one byte shorter than what the descriptor lengths add up to, and the last byte will be zeroed in fuse_copy_folios().
This also fixes a bug in virtio-fs that existed before any iomap changes were added to fuse. For virtio-fs, data there arrives by DMA rather than through fuse_copy_folios(), so the only zeroing is in virtio_fs_request_complete(), which compares the reply size against the descriptor length. With the descriptor length shortened, the two are equal and nothing gets zeroed, which means the unrequested byte is left holding whatever was in the folio, when the folio is marked uptodate. This is both in the fuse_do_readfolio() and fuse_send_readpages() paths. This dates back to commit 2f1398291bf3 ("fuse: don't overflow LLONG_MAX with end offset").
--- fs/fuse/file.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-)
fs/fuse/file.c +29 -9
@@ -864,18 +864,29 @@ static int fuse_do_readfolio(struct file *file, struct folio *folio, attr_ver =fuse_get_attr_version (fm->fc); -/* Don't overflow end offset */ -if (pos + (desc.length -1 ) ==LLONG_MAX ) - desc.length--; +/* +* Don't overflow end offset. +* +* Ask the server for len - 1 bytes. desc.length still holds the full +* length. When the reply comes back, it will be one byte shorter than +* desc.length and fuse_copy_folios() will zero that last byte. +* +* For this reason, desc.length must not be decremented too. The caller +* reports the full length to iomap_finish_folio_read(), which marks +* every block it covers uptodate. Shortening the descriptor would +* suppress zeroing and leave the last byte holding stale data. +*/ +if (pos + (len -1 ) ==LLONG_MAX ) + len--; -fuse_read_args_fill (&ia, file, pos, desc.length,FUSE_READ ); +fuse_read_args_fill (&ia, file, pos, len,FUSE_READ ); res =fuse_simple_request (fm, &ia.ap.args);if (res <0 )return res;/* * Short read means EOF. If file size is larger, truncate it */ -if (res < desc.length) +if (res < len)fuse_short_read (inode, attr_ver, res, &ia.ap);return 0 ;
@@ -1068,11 +1079,20 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file, ap->args.page_zeroing = true; ap->args.page_replace = true; -/* Don't overflow end offset */ -if (pos + (count -1 ) ==LLONG_MAX ) { +/* +* Don't overflow end offset. +* +* Ask the server for count - 1 bytes. The reply is then one byte +* shorter than what the descriptor lengths add up to, so +* fuse_copy_folios() zeroes the last byte when it walks the folios. +* +* ap->descs[] must not be decremented here. It is what +* fuse_readpages_end() reports back to iomap_finish_folio_read(), and +* iomap has already accounted the full descriptor length, so shortening +* it would leave ifs->read_bytes_pending nonzero and the folio locked. +*/ +if (pos + (count -1 ) ==LLONG_MAX ) count--; - ap->descs[ap->num_folios -1 ].length--; - }WARN_ON ((loff_t) (pos + count) <0 );fuse_read_args_fill (ia, file, pos, count,FUSE_READ );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 300/1257 fuse: dont drop destination page cache on a zero byte copy reply
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joanne Koong <[email protected]>
[ Upstream commit f7585e1ce3418ec282485854b3d8d31c6a961e37 ]
__fuse_copy_file_range() clears the destination page cache after the server replies:
truncate_inode_pages_range(inode_out->i_mapping, ALIGN_DOWN(pos_out, PAGE_SIZE), ALIGN(pos_out + bytes_copied, PAGE_SIZE) - 1);
A server may legitimately reply that it copied nothing, eg if the source file turns out to be shorter than the size the kernel has cached for it.
If pos_out is 0 as well, the end of the range is ALIGN(0, PAGE_SIZE) - 1, which is -1. lend is a uoff_t and truncate_inode_pages_range() takes -1 as its end of file sentinel, so rather than clearing nothing it drops every folio in the destination mapping.
That is not only a cache drop. truncate_cleanup_folio() calls folio_cancel_dirty(), and fuse_writeback_range() only wrote back [pos_out, pos_out + len - 1], so dirty data elsewhere in the destination file is discarded without ever reaching the server.
Skip the call when the server copied nothing, since there is nothing stale to clear in that case.
--- fs/fuse/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/fuse/file.c +5 -3
@@ -3058,9 +3058,11 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in, goto out; } -truncate_inode_pages_range (inode_out->i_mapping, -ALIGN_DOWN (pos_out,PAGE_SIZE ), -ALIGN (pos_out + bytes_copied,PAGE_SIZE ) -1 ); +if (bytes_copied) +truncate_inode_pages_range (inode_out->i_mapping, +ALIGN_DOWN (pos_out,PAGE_SIZE ), +ALIGN (pos_out + bytes_copied, +PAGE_SIZE ) -1 );file_update_time (file_out);fuse_write_update_attr (inode_out, pos_out + bytes_copied, bytes_copied);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 301/1257 platform/x86/intel/pmt: Block mmap when callback is present
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael J. Ruhl <[email protected]>
[ Upstream commit 0d4cd92b41dd33a3112959f9be86002ff309de73 ]
With the introduction of the .read_telem() callback, control for access to a devices data area must be done by the callback owner.
This means that an area cannot be mmap-ed with the default PMT handler.
If the .read_telem() callback is present, do not support mmap.
--- drivers/platform/x86/intel/pmt/class.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/pmt/class.c +8 -1
@@ -417,7 +417,14 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,sysfs_bin_attr_init (&entry->pmt_bin_attr); entry->pmt_bin_attr.attr.name = ns->name; entry->pmt_bin_attr.attr.mode =0440 ; - entry->pmt_bin_attr.mmap = intel_pmt_mmap; + +/* +* The read_telem callback controls access to the memory area. Block +* usage if the read_telem callback is present. +*/ +if (!(entry->cb && entry->cb->read_telem)) + entry->pmt_bin_attr.mmap = intel_pmt_mmap; + entry->pmt_bin_attr.read = intel_pmt_read; entry->pmt_bin_attr.size = entry->size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 302/1257 mtd: rawnand: nuvoton: fix clock cleanup on probe failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 8a485a40f45a19c5fcafb5cbee7387c2762af7c4 ]
ma35_nand_probe() gets and enables the NAND clock with devm_clk_get_enabled(), but the ma35_nand_chips_init() failure path also calls clk_disable() before returning.
devm_clk_get_enabled() registers a managed cleanup that calls clk_disable_unprepare() on probe failure and driver removal. Calling clk_disable() explicitly first drops the clock enable count, so the managed cleanup attempts to disable the clock again and triggers the clock framework warning for an already disabled clock.
Remove the redundant clk_disable() and let the managed clock cleanup handle the clock state.
This issue was found by manual code inspection.
--- drivers/mtd/nand/raw/nuvoton-ma35d1-nand-controller.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/nand/raw/nuvoton-ma35d1-nand-controller.c +0 -1
@@ -993,7 +993,6 @@ static int ma35_nand_probe(struct platform_device *pdev) ret =ma35_nand_chips_init (&pdev->dev, nand);if (ret) {dev_err (&pdev->dev,"failed to init NAND chips\n" ); -clk_disable (nand->clk);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 303/1257 mtd: rawnand: atmel: Fix MCK clock leak in atmel_nand_controller_init()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 94edcda45d888c3bb1310de11e10e4537c166f00 ]
atmel_nand_controller_init() takes a reference to the MCK clock with of_clk_get() and keeps it in nc->mck for the lifetime of the controller. If the "atmel,smc" phandle is missing or the SMC regmap cannot be obtained afterwards, the error path jumps to out_release_dma which only releases the DMA channel, so the clock reference is leaked. The callers return the error directly and never run atmel_nand_controller_cleanup(), where the clock is normally put.
Release the reference on those error paths. The path on which of_clk_get() itself fails keeps jumping to out_release_dma, as nc->mck only holds an error pointer there.
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +4 -2
@@ -2085,7 +2085,7 @@ static int atmel_nand_controller_init(struct atmel_nand_controller *nc,if (!np) {dev_err (dev,"Missing or invalid atmel,smc property\n" ); ret = -EINVAL ; - goto out_release_dma; + goto out_put_mck; } nc->smc =syscon_node_to_regmap (np);
@@ -2093,11 +2093,13 @@ static int atmel_nand_controller_init(struct atmel_nand_controller *nc,if (IS_ERR (nc->smc)) { ret =PTR_ERR (nc->smc);dev_err (dev,"Could not get SMC regmap (err = %d)\n" , ret); - goto out_release_dma; + goto out_put_mck; }return 0 ; +out_put_mck: +clk_put (nc->mck); out_release_dma:if (nc->dmac)dma_release_channel (nc->dmac);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 304/1257 mtd: maps: pci: balance PCI enable on cleanup
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 3be16e5d4990bf96309ac5ba35cb369c6015bce7 ]
mtd_pci_probe() leaves the PCI device enabled on later probe failure and mtd_pci_remove() does not disable it either. Use pcim_enable_device() to release the enable reference after the existing map and region cleanup.
The imbalance is already present in the initial Git import.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/mtd/maps/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/pci.c +1 -1
@@ -250,7 +250,7 @@ static int mtd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)struct mtd_info *mtd =NULL ;int err; - err =pci_enable_device (dev); + err =pcim_enable_device (dev);if (err) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 305/1257 mtd: cfi_cmdset_0002: cap the write-buffer chunk at 256 bytes on an x8 device
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit cfc5ebc9540e29f8f96db88bbfa261139e5afedb ]
The Write to Buffer command takes the number of words to program minus one, and do_write_buffer() sends that count as a single bus word:
map_write(map, CMD(words - 1), cmd_adr);
CMD() replicates the value into every device lane, so each device reads the count off its own data lines - eight of them on an x8 part. A count that does not fit in eight bits is truncated there, which limits one Write to Buffer to 256 words on an x8 device, however large a buffer the chip advertises in its CFI query.
The M29EW on a Cavium Octeon CN6335 board (an x16 part strapped to x8) advertises MaxBufWriteSize = 512 bytes, so cfi_amdstd_write_buffers() split the data into 512-byte chunks and do_write_buffer() sent a count of
511. The chip saw 511 & 0xff = 255, expected 256 bytes, and aborted the program when the 257th arrived. Chunks below 256 bytes - the leading partial chunk of a write - completed normally, so only the full-size ones failed:
MTD do_write_buffer_wait(): software timeout, address:0x03278bff.
jffs2: Write of 4164 bytes at 0x02c789b4 failed. returned -5, retlen 68
jffs2: No space for garbage collection. Aborting GC thread
Clamp MaxBufWriteSize for x8 devices in the write-buffer fixup, and recompute mtd->writebufsize, which cfi_cmdset_0002_setup() derives from MaxBufWriteSize before the fixups run.
The clamp deliberately keys off the device width rather than the part, even though the driver already recognises this one in is_m29ew(): the ceiling comes from the width of a device's data bus, not from the chip, so any x8 device advertising a larger buffer is told a count it cannot receive. The M29EW is only where it was found.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +15 -0
@@ -283,6 +283,21 @@ static void fixup_use_write_buffers(struct mtd_info *mtd)pr_debug ("Using buffer write method\n" ); mtd->_write = cfi_amdstd_write_buffers; } + +/* +* The word count of the Write to Buffer command is a single bus +* word per device, so an x8 device can be told to program at most +* 256 bytes however large a buffer it advertises - including when +* several of them are interleaved on a wider bus, where CMD() +* replicates the count into each device's lane and it is truncated +* there. +*/ +if (cfi->device_type ==CFI_DEVICETYPE_X8 && + cfi->cfiq->MaxBufWriteSize >8 ) { + cfi->cfiq->MaxBufWriteSize =8 ; + mtd->writebufsize =cfi_interleave (cfi) << + cfi->cfiq->MaxBufWriteSize; + } }#endif /* !FORCE_WORD_WRITE */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 306/1257 mtd: amd76xrom: Fix PCI device reference leak in amd76xrom_init_one()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 1a122f5fecbabd47b81b1be3f0934f57b78aad42 ]
init_amd76xrom() obtains the PCI device with pci_get_device() and hands the reference over to amd76xrom_init_one(), which stores it in window->pdev. When reserving the ROM window fails, that function returns -EBUSY directly instead of going through amd76xrom_cleanup(), so the reference is neither released nor cleared.
Drop the reference and clear window->pdev on that path.
--- drivers/mtd/maps/amd76xrom.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/maps/amd76xrom.c +2 -0
@@ -152,6 +152,8 @@ static int amd76xrom_init_one(struct pci_dev *pdev, printk(KERN_ERR MOD_NAME" %s(): Unable to register resource %pR - kernel bug?\n" , __func__, &window->rsrc); +pci_dev_put (window->pdev); + window->pdev =NULL ;return -EBUSY ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 307/1257 mtd: maps: l440gx: Fix double put of the ISA bridge in init_l440gx()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 521ad948e04934b2d70ae899bc016bbb38802e90 ]
init_l440gx() takes a single reference on the PIIX4 ISA bridge with pci_get_device() and drops it again right after the lookups, before the flash window is set up. The pci_assign_resource() failure path then calls pci_dev_put() on the same device a second time, releasing a reference that is no longer owned and underflowing the reference count.
Remove the extra pci_dev_put().
--- drivers/mtd/maps/l440gx.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/maps/l440gx.c +0 -1
@@ -110,7 +110,6 @@ static int __init init_l440gx(void)/* Allocate the resource region */ if (pci_assign_resource (pm_dev,PIIXE_IOBASE_RESOURCE ) !=0 ) { -pci_dev_put (dev);pci_dev_put (pm_dev);printk (KERN_WARNING "Could not allocate pm iobase resource\n" );iounmap (l440gx_map.virt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 308/1257 mtd: maps: l440gx: Fix double put of the PM device in init_l440gx()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit e6ca524ee5b2705be30ea19ce2e55122d9f9ed8f ]
The PIIX4 PM device reference taken with pci_get_device() is dropped again before the iobase resource is allocated. If pci_assign_resource() fails, the error path calls pci_dev_put() on pm_dev a second time, releasing a reference that is no longer owned and underflowing the reference count.
Remove the extra pci_dev_put().
--- drivers/mtd/maps/l440gx.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/maps/l440gx.c +0 -1
@@ -110,7 +110,6 @@ static int __init init_l440gx(void)/* Allocate the resource region */ if (pci_assign_resource (pm_dev,PIIXE_IOBASE_RESOURCE ) !=0 ) { -pci_dev_put (pm_dev);printk (KERN_WARNING "Could not allocate pm iobase resource\n" );iounmap (l440gx_map.virt);return -ENXIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 309/1257 mtd: mtdsuper: Fix MTD device reference leak in mtd_get_sb()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 62ee3da38f41bef83c1cf250f6816a0ee187674b ]
mtd_get_sb() is called with a reference to the MTD device already taken by the caller. When sget_dev() fails, the function returns the error without dropping that reference, so the device is never released and its refcount never reaches zero. Every mount attempt on an MTD device whose superblock cannot be set up leaks a reference.
Restore the put_mtd_device() that the fs_context conversion dropped on this path.
--- drivers/mtd/mtdsuper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/mtdsuper.c +3 -1
@@ -31,8 +31,10 @@ static int mtd_get_sb(struct fs_context *fc,int ret; sb =sget_dev (fc,MKDEV (MTD_BLOCK_MAJOR , mtd->index)); -if (IS_ERR (sb)) +if (IS_ERR (sb)) { +put_mtd_device (mtd);return PTR_ERR (sb); + }if (sb->s_root) {/* new mountpoint for an already mounted superblock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 310/1257 mtd: Call get_wunit() on the master partition
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
[ Upstream commit 904f18430e8cce829cb9130eab7a93020e33fc89 ]
The code checks whether master has get_wunit() but still calls it on the child. Fix this.
--- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdcore.c +1 -1
@@ -563,7 +563,7 @@ int mtd_pairing_info_to_wunit(struct mtd_info *mtd,return -EINVAL ;if (master->pairing && master->pairing->get_wunit) -return mtd->pairing->get_wunit (master, info); +return master->pairing->get_wunit (master, info);return info->pair; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 311/1257 hwmon: (coretemp) Refresh the temperature on the first read
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Neri <[email protected]>
[ Upstream commit e463cd582ca125e359ad1a66cb076434c14638b2 ]
show_temp() reads the status MSR only when the cached temperature is older than one second. Commit 5c0e64dde80f ("hwmon: (coretemp) Remove obsolete temp_data->valid") dropped the tdata->valid check that used to force the very first read, leaving that comparison as the only trigger.
A never-updated temp_data carries a zero timestamp, which does not look stale on 32-bit kernels: jiffies starts 300 seconds short of wrapping, so the comparison stays false until jiffies wraps and passes HZ. For the first 301 seconds of uptime temp%d_input reports the zero left by the allocator rather than the CPU temperature. 64-bit kernels are
unaffected: jiffies starts at a positive value there and does not wrap.
Backdate the timestamp when the temperature data is allocated. One jiffy older than the caching interval is stale under either word size, and the first refresh overwrites it.
--- drivers/hwmon/coretemp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwmon/coretemp.c +5 -0
@@ -511,6 +511,11 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag) tdata->cpu = cpu; tdata->cpu_core_id =topology_core_id (cpu); tdata->attr_size =MAX_CORE_ATTRS ; +/* +* A zero timestamp does not look stale on 32-bit, where jiffies +* starts just short of wrapping. Backdate it instead. +*/ + tdata->last_updated = jiffies -HZ -1 ;mutex_init (&tdata->update_lock);return tdata; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 312/1257 dcache: report a Tasks-RCU quiescent state in dentry_kill()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit a647a53bc89a046bee4a12a0a5627f2dfaaef807 ]
I am constantly seeing the following warning on Meta's fleet:
INFO: rcu_tasks detected stalls on tasks:
native_queued_spin_lock_slowpath
locked_inode_to_wb_and_lock_list
inode_io_list_del
evict
__dentry_kill
shrink_dentry_list
shrink_dcache_tree
d_invalidate
btrfs_delete_subvolume
btrfs_ioctl_snap_destroy
btrfs_ioctl
do_syscall_64dentry_kill() is the common funnel for dentry teardown: dput(), shrink_dentry_list() and shrink_dcache_tree() all reach it, once per dentry, and its cond_resched() is the only reschedule point on that path.
cond_resched() is not an RCU-tasks quiescent state.
Use cond_resched_tasks_rcu_qs() so the teardown reports an RCU-tasks quiescent state as it proceeds.
--- fs/dcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dcache.c +1 -1
@@ -843,7 +843,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)if (dentry->d_op && dentry->d_op->d_release) dentry->d_op->d_release (dentry); -cond_resched (); +cond_resched_tasks_rcu_qs ();/* now that it's negative, ->d_parent is stable */ if (!IS_ROOT (dentry)) { parent = dentry->d_parent;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 313/1257 ASoC: sdw_utils: clear stale RT711 device reference on exit
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Cemin <[email protected]>
[ Upstream commit 7c7df141dcabaa5370b5e52a9d64e2c1ea13a338 ]
asoc_sdw_rt711_exit() drops the reference held in ctx->headset_codec_dev but leaves the pointer populated. If the card cleanup path reaches the exit hook more than once after a failed or deferred probe, a later invocation reuses the stale pointer and calls put_device() again, underflowing the refcount and leading to oopses when later probe, driver bind, or suspend paths walk the SoundWire bus after the device reference was released. Observed as boot- and suspend-time oopses on an arm64 platform with an RT712 headset codec, reproducible deterministically by repeated machine-driver probe cycling with the codec drivers unloaded.
Clear the pointer after put_device() so repeated cleanup becomes a no-op, which also makes the existing NULL check at the top of the exit hook effective. This matches what commit 046173b98de3 ("ASoC: sdw_utils:
fix double put_device() on aggregated amps") did for the aggregated amp references.
--- sound/soc/sdw_utils/soc_sdw_rt711.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/sdw_utils/soc_sdw_rt711.c +1 -0
@@ -124,6 +124,7 @@ int asoc_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_device_remove_software_node (ctx->headset_codec_dev);put_device (ctx->headset_codec_dev); + ctx->headset_codec_dev =NULL ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 314/1257 ASoC: wcd9335: Fix device reference leak in wcd9335_slim_status()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
[ Upstream commit f0cc352be29ba616e0682f66f551d3f3029886fd ]
wcd9335_slim_status() obtains the SLIM interface device with of_slim_get_device(), which uses device_find_child() internally and returns the device with a reference held. As the device_find_child() documentation says: you will need to drop the reference with put_device() after use. The reference is stored in wcd->slim_ifc_dev and never dropped, so the SLIM interface device cannot be released. Fix it by using devm_add_action_or_reset() or put_device() respectively.
Found by code review.
--- sound/soc/codecs/wcd9335.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/soc/codecs/wcd9335.c +12 -0
@@ -5096,6 +5096,13 @@ static int wcd9335_slim_probe(struct slim_device *slim)return 0 ; } +static void wcd9335_put_device_action (void *data) +{ +struct device *dev = data; + +put_device (dev); +} +static int wcd9335_slim_status (struct slim_device *sdev,enum slim_device_status status) {
@@ -5120,6 +5127,11 @@ static int wcd9335_slim_status(struct slim_device *sdev,return -EINVAL ; } + ret =devm_add_action_or_reset (dev, wcd9335_put_device_action, + &wcd->slim_ifc_dev->dev); +if (ret) +return ret; +slim_get_logical_addr (wcd->slim_ifc_dev); wcd->regmap =regmap_init_slimbus (sdev, &wcd9335_regmap_config);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 315/1257 peci: aspeed: Initialize state before requesting IRQ
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 61cf765b654b76a62510269521a65e4e4a488f4c ]
The PECI interrupt handler uses the lock and completion object as soon as the interrupt is delivered. Initialize both before registering the handler so an early interrupt cannot access uninitialized state.
--- drivers/peci/controller/peci-aspeed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/peci/controller/peci-aspeed.c +3 -3
@@ -529,14 +529,14 @@ static int aspeed_peci_probe(struct platform_device *pdev)if (priv->irq <0 )return priv->irq; +init_completion (&priv->xfer_complete); +spin_lock_init (&priv->lock); + ret =devm_request_irq (&pdev->dev, priv->irq, aspeed_peci_irq_handler,0 ,"peci-aspeed" , priv);if (ret)return ret; -init_completion (&priv->xfer_complete); -spin_lock_init (&priv->lock); - priv->rst =devm_reset_control_get (&pdev->dev,NULL );if (IS_ERR (priv->rst)) return dev_err_probe(priv->dev, PTR_ERR(priv->rst),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 316/1257 peci: npcm: Initialize state before requesting IRQ
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 425125e6d408b5969afb99c3e95a391f1f1ad81d ]
The PECI interrupt handler uses the lock and completion object as soon as the interrupt is delivered. Initialize both before registering the handler so an early interrupt cannot access uninitialized state.
--- drivers/peci/controller/peci-npcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/peci/controller/peci-npcm.c +3 -3
@@ -253,14 +253,14 @@ static int npcm_peci_probe(struct platform_device *pdev)if (priv->irq <0 )return priv->irq; +init_completion (&priv->xfer_complete); +spin_lock_init (&priv->lock); + ret =devm_request_irq (&pdev->dev, priv->irq, npcm_peci_irq_handler,0 ,"peci-npcm-irq" , priv);if (ret)return ret; -init_completion (&priv->xfer_complete); -spin_lock_init (&priv->lock); - ret =npcm_peci_init_ctrl (priv);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 317/1257 hwmon: (tmp102) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 56c1d32323e773b8b927316f8beeae9238576335 ]
tmp102 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the first ~35 ms conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp102.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp102.c +4 -4
@@ -58,7 +58,7 @@ struct tmp102 {const char *label;struct regmap *regmap;u16 config_orig; -unsigned long ready_time; +u64 ready_time;u16 sample_time; };
@@ -106,7 +106,7 @@ static int tmp102_read_temp(struct device *dev, u32 attr, long *val)switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp102->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp102->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ; }
@@ -354,7 +354,7 @@ static int tmp102_probe(struct i2c_client *client)* Mark that we are not ready with data until the first * conversion is complete */ - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS ); hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, tmp102,
@@ -387,7 +387,7 @@ static int tmp102_resume(struct device *dev) err =regmap_update_bits (tmp102->regmap,TMP102_CONF_REG ,TMP102_CONF_SD ,0 ); - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 318/1257 hwmon: (tmp108) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 6b8b1d1d7bc7e579b53fc7c3293b787d68de702a ]
tmp108 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the initial conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot. The continuous-mode path, which sets ->ready_time to jiffies with no added conversion delay, wraps the same way.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp108.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp108.c +4 -4
@@ -78,7 +78,7 @@struct tmp108 {struct regmap *regmap;u16 orig_config; -unsigned long ready_time; +u64 ready_time;const struct tmp108_params *params; };
@@ -138,7 +138,7 @@ static int tmp108_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp108->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp108->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ;
@@ -477,7 +477,7 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *return err; } - tmp108->ready_time = jiffies; + tmp108->ready_time =get_jiffies_64 ();if ((tmp108->orig_config &TMP108_CONF_MODE_MASK ) ==TMP108_MODE_SHUTDOWN ) tmp108->ready_time +=
@@ -528,7 +528,7 @@ static int tmp108_resume(struct device *dev) err =regmap_update_bits (tmp108->regmap,TMP108_REG_CONF ,TMP108_CONF_MODE_MASK ,TMP108_MODE_CONTINUOUS ); - tmp108->ready_time = jiffies + + tmp108->ready_time =get_jiffies_64 () +msecs_to_jiffies (TMP108_CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 319/1257 MIPS: mm: align hugetlb mappings in arch_get_unmapped_area()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit 975d4a6a6d4d23a39e2f49cafcc082d937960bc4 ]
Since hugetlb mappings were made to go through the architecture's arch_get_unmapped_area{,_topdown}(), every architecture that implements those has to align hugetlb files itself. The generic implementation and loongarch do it with huge_page_mask_align(); MIPS was left out.
A non-MAP_FIXED mmap() of a hugetlbfs file therefore returns an address that is only SHMLBA aligned, and the kernel then installs 2 MB PMDs for a VMA that starts in the middle of a PMD. The consequences on an Octeon (CN63XX) board running a process that links libhugetlbfs with HUGETLB_ELFMAP=R and HUGETLB_MORECORE=yes, all within a minute of
start: the neighbouring 4 KB page table is clobbered, the TLB ends up with overlapping entries ("Caught Machine Check exception - caused by multiple matching entries in the TLB"), process exit trips BUG_ON(start & ~huge_page_mask(h)) in __unmap_hugepage_range(), and freed pages leak into unrelated kernel structures (oopses in the irq maple tree, in pte_offset_map, ...).
Do what loongarch does in commit 3109d5ff484b ("LoongArch: Set hugetlb mmap base address aligned with pmd size"): when the file is a hugetlb file, use its page mask as the search alignment instead of the cache colour mask.
--- arch/mips/mm/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/mips/mm/mmap.c +5 -1
@@ -9,6 +9,7 @@#include <linux/compiler.h> #include <linux/elf-randomize.h> #include <linux/errno.h> +#include <linux/hugetlb.h> #include <linux/mm.h> #include <linux/mman.h> #include <linux/export.h>
@@ -72,8 +73,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp, } info.length = len; - info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) :0 ; info.align_offset = pgoff <<PAGE_SHIFT ; +if (filp &&is_file_hugepages (filp)) + info.align_mask =huge_page_mask_align (filp); +else + info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) :0 ;if (dir ==DOWN ) { info.flags =VM_UNMAPPED_AREA_TOPDOWN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 320/1257 MIPS: mm: do not write a huge TLB entry when the probe misses
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit 0cb17268887e1df5c425ea052f5146b42d126323 ]
__update_tlb() probes for the 8K pair at the address it is given and, for a huge pmd, writes the huge entry with tlbwi at the probed index or with tlbwr when the probe misses. That works only if the caller passes the faulting address, so that the probe finds the 4K entry the refill handler loaded for the faulting page and the huge entry replaces it.
update_mmu_cache_pmd() is not called that way. do_set_pmd() has always passed the huge-aligned address, and since commit ebcfc63d6bca ("mm:
abstract THP allocation") the anonymous THP fault path does too (map_anon_folio_pmd()). The probe then misses the stale 4K entry, which sits at the faulting page somewhere else in the 2 MB range, tlbwr adds a huge entry next to it, and the TLB holds two entries matching the faulting address. Octeon raises "Machine Check exception - caused by multiple matching entries in the TLB" on the next refill of that page; a process on a CN63XX board died this way within a second of start, on the first anonymous THP of its bss.
Skip the write when the probe misses. The refill and TLBL/TLBS handlers probe the faulting address themselves and rewrite the stale entry with the huge one (they also set the software young bit), so the entry is installed on the next access at the cost of one exception.
--- arch/mips/mm/tlb-r4k.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
arch/mips/mm/tlb-r4k.c +17 -4
@@ -332,6 +332,19 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)/* this could be a huge page */ if (pmd_leaf (*pmdp)) {unsigned long lo; + +/* +* The probe above only covers the 8K pair at @address, and +* a huge mapping is installed with the huge-aligned address +* while the refill that started the fault left a 4K entry +* for the faulting page elsewhere in the range. Writing the +* huge entry to a random index would leave two entries +* matching the faulting address; leave it to the refill and +* TLBL/TLBS handlers, which probe the faulting address. +*/ +if (idx <0 ) + goto out; +write_c0_pagemask (PM_HUGE_MASK ); ptep = (pte_t *)pmdp; lo =pte_to_entrylo (pte_val (*ptep));
@@ -339,10 +352,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)write_c0_entrylo1 (lo + (HPAGE_SIZE >>7 ));mtc0_tlbw_hazard (); -if (idx <0 ) -tlb_write_random (); -else -tlb_write_indexed (); +tlb_write_indexed ();tlbw_use_hazard ();write_c0_pagemask (PM_DEFAULT_MASK ); }else
@@ -380,6 +390,9 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)tlb_write_indexed (); }tlbw_use_hazard (); +#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT +out: +#endif htw_start ();flush_micro_tlb_vm (vma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/1257 netfilter: ctnetlink: fix inverted IPv6 address match in dump filter
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piotr Kubik <[email protected]>
[ Upstream commit 1ae2d094b0200f687923298c0e42579273558988 ]
ctnetlink_filter_match_tuple() rejects an entry when !ipv6_addr_cmp(filter, entry) is true. ipv6_addr_cmp() is a memcmp() and returns 0 for equal addresses, so the condition is true exactly when the addresses match: a CTA_FILTER dump with an IPv6 CTA_IP_SRC or CTA_IP_DST skips every entry that matches the requested address and returns all the others. The IPv4 branch compares with != and behaves correctly.
Observed with libnetfilter_conntrack NFCT_FILTER_DUMP_TUPLE: a dump filtered on src 2001:db8::10 returned only the unrelated entries, and a dump filtered on ::1 returned every entry except the ::1 ones. conntrack-tools does not use the tuple filter for -L, which is why this went unnoticed.
Use ipv6_addr_equal() so the IPv6 branch mirrors the IPv4 one.
--- net/netfilter/nf_conntrack_netlink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_netlink.c +4 -4
@@ -1098,13 +1098,13 @@ static int ctnetlink_filter_match_tuple(struct nf_conntrack_tuple *filter_tuple,break ;case NFPROTO_IPV6 :if ((flags &CTA_FILTER_FLAG (CTA_IP_SRC )) && - !ipv6_addr_cmp (&filter_tuple->src.u3.in6, - &ct_tuple->src.u3.in6)) + !ipv6_addr_equal (&filter_tuple->src.u3.in6, + &ct_tuple->src.u3.in6))return 0 ;if ((flags &CTA_FILTER_FLAG (CTA_IP_DST )) && - !ipv6_addr_cmp (&filter_tuple->dst.u3.in6, - &ct_tuple->dst.u3.in6)) + !ipv6_addr_equal (&filter_tuple->dst.u3.in6, + &ct_tuple->dst.u3.in6))return 0 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/1257 arm64: dts: qcom: sdm845-xiaomi-beryllium: Extend the xbl_mem region
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit 511c4fea32708a065e03503c0e4d44f48990c530 ]
Xiaomi's Oreo-era tree still had the CAF 1 MiB region, the 2 MiB version arrived with the Pie import. This isn't a board-layout quirk, it tracks the firmware. The later XBL wants one extra MiB below the old region.
--- .../arm64/boot/dts/qcom/sdm845-xiaomi-beryllium-common.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium-common.dtsi +6 -0
@@ -27,6 +27,7 @@ /delete-node/ &slpi_mem; /delete-node/ &spss_mem; /delete-node/ &rmtfs_mem; +/delete-node/ &xbl_mem; / { chassis-type = "handset";
@@ -71,6 +72,11 @@ key-vol-up { /* Reserved memory changes from downstream */ reserved-memory { + xbl-mem@85d00000 { + reg = <0 0x85d00000 0 0x200000>; + no-map; + }; + tz_mem: memory@86200000 { reg = <0 0x86200000 0 0x4900000>; no-map;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 323/1257 arm64: dts: qcom: sdm845-xiaomi-polaris: Extend the xbl_mem region
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit 38458f12419f456b16385c118bcacd76899d99b9 ]
Xiaomi's Oreo-era tree still had the CAF 1 MiB region, the 2 MiB version arrived with the Pie import. This isn't a board-layout quirk, it tracks the firmware. The later XBL wants one extra MiB below the old region.
--- arch/arm64/boot/dts/qcom/sdm845-xiaomi-polaris.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-xiaomi-polaris.dts +6 -0
@@ -32,6 +32,7 @@ /delete-node/ &mba_region; /delete-node/ &slpi_mem; /delete-node/ &spss_mem; +/delete-node/ &xbl_mem; / { model = "Xiaomi Mi MIX 2S";
@@ -63,6 +64,11 @@ key-vol-up { }; reserved-memory { + xbl-mem@85d00000 { + reg = <0 0x85d00000 0 0x200000>; + no-map; + }; + adsp_mem: memory@8c500000 { reg = <0 0x8c500000 0 0x1e00000>; no-map;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 324/1257 arm64: dts: qcom: ipq9574: Wire up USB3 PHY PIPE clock to GCC
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kathiravan Thirumoorthy <[email protected]>
[ Upstream commit 117d8d40be1ded4f35f3252efa83607a7134d5e0 ]
Connect the QMP PHY USB3 output to GCC so the USB3 PHY pipe clock can propagate to the USB controller.
--- arch/arm64/boot/dts/qcom/ipq9574.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq9574.dtsi +1 -1
@@ -428,7 +428,7 @@ gcc: clock-controller@1800000 { <&pcie1_phy>, <&pcie2_phy>, <&pcie3_phy>, - <0>; + <&usb_0_qmpphy>; #clock-cells = <1>; #reset-cells = <1>; #interconnect-cells = <1>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 325/1257 iommu/vt-d: Avoid out-of-range shift in qi_desc_dev_iotlb_pasid()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit ddea230c9fc28d1f2090ceeab3d66ce2bea658e9 ]
Callers request a full Device-TLB flush by passing MAX_AGAW_PFN_WIDTH (64 - VTD_PAGE_SHIFT == 52) as @size_order. Two expressions in qi_desc_dev_iotlb_pasid() are not prepared for a value that large:
unsigned long mask = 1UL << (VTD_PAGE_SHIFT + size_order - 1); ... if (!IS_ALIGNED(addr, VTD_PAGE_SIZE << size_order))
The second evaluates to 1UL << 64, which is undefined on all architectures. On x86_64 the shift count masks to zero, IS_ALIGNED(addr,
1) is trivially true, and the alignment sanity check silently degrades into a no-op.
The first evaluates to 1UL << 63. That is well defined on 64-bit builds, where unsigned long is 64 bits wide, but is undefined on 32-bit ones. In practice x86 masks the shift count to five bits, so the expression yields 1UL << 31 and ~mask becomes 0x7fffffff. That value is zero-extended when applied to the 64-bit descriptor, so
desc->qw1 &= ~mask;
clears qw1[63:32] as well as bit 31, collapsing the ADDR field that had just been filled with ones. Reaching that requires a scalable-mode PASID configuration on 32-bit x86, which is not a realistic deployment, but the construct is wrong regardless.
Compute the mask with BIT_ULL() so that it is 64-bit on every architecture, and skip the alignment check for a full flush, where it is both meaningless and the source of the out-of-range shift.
Note that @size_order must not be clamped below 64 - VTD_PAGE_SHIFT. With S set, hardware derives the invalidation range from the least significant zero bit N of ADDR and matches bits [63:N+1] of the incoming address. For size_order 52 the descriptor sets ADDR[63:12] and clears bit 63, making N = 63 and the comparison range empty, so everything is invalidated. Reducing @size_order to 51 would instead leave N = 62 and cause hardware to compare address bit 63; since callers pass an address of 0, only the lower half of the address space would be invalidated. Bound @size_order at 64 - VTD_PAGE_SHIFT so that a bogus caller cannot reintroduce an out-of-range shift, without altering the full-flush encoding.
The non-PASID variant qi_desc_dev_iotlb() already uses 1ULL and is unaffected.
--- drivers/iommu/intel/iommu.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.h +13 -4
@@ -1105,12 +1105,20 @@ static inline void qi_desc_dev_iotlb_pasid(u16 sid, u16 pfsid, u32 pasid,unsigned int size_order, struct qi_desc *desc) { - unsigned long mask = 1UL << (VTD_PAGE_SHIFT + size_order - 1); - desc->qw0 = QI_DEV_EIOTLB_PASID(pasid) | QI_DEV_EIOTLB_SID(sid) |QI_DEV_EIOTLB_QDEP (qdep) |QI_DEIOTLB_TYPE |QI_DEV_IOTLB_PFSID (pfsid); +/* +* The widest range the descriptor can express is a full flush, encoded +* by making bit 63 the least significant zero bit of ADDR, that is +* @size_order == 64 - VTD_PAGE_SHIFT. Bound @size_order there so that +* a caller passing something larger cannot produce an out-of-range +* shift below. +*/ +if (size_order >64 -VTD_PAGE_SHIFT ) + size_order =64 -VTD_PAGE_SHIFT ; +/* * If S bit is 0, we only flush a single page. If S bit is set, * The least significant zero bit indicates the invalidation address
@@ -1120,7 +1128,8 @@ static inline void qi_desc_dev_iotlb_pasid(u16 sid, u16 pfsid, u32 pasid,* Max Invs Pending (MIP) is set to 0 for now until we have DIT in * ECAP. */ -if (!IS_ALIGNED (addr,VTD_PAGE_SIZE << size_order)) +if (size_order <64 -VTD_PAGE_SHIFT && + !IS_ALIGNED (addr,BIT_ULL (VTD_PAGE_SHIFT + size_order)))pr_warn_ratelimited ("Invalidate non-aligned address %llx, order %d\n" , addr, size_order);
@@ -1136,7 +1145,7 @@ static inline void qi_desc_dev_iotlb_pasid(u16 sid, u16 pfsid, u32 pasid, desc->qw1 |=GENMASK_ULL (size_order +VTD_PAGE_SHIFT -1 ,VTD_PAGE_SHIFT );/* Clear size_order bit to indicate size */ - desc->qw1 &= ~mask; + desc->qw1 &= ~BIT_ULL (VTD_PAGE_SHIFT + size_order -1 );/* Set the S bit to indicate flushing more than 1 page */ desc->qw1 |=QI_DEV_EIOTLB_SIZE ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/1257 fuse: fix GCC 8 build with CONFIG_PROFILE_ALL_BRANCHES
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 6e887377a63f670d79f3d8a107f29e745e9ddf43 ]
Commit 25307ca50b815 ("fuse: simplify logic in fuse_notify_store() and fuse_retrieve()") introduced a loff_t cursor and used it in place of outarg's offset field. In the min() expression this changed the second operand from unsigned to signed.
With CONFIG_PROFILE_ALL_BRANCHES, GCC 8 does not propagate the range established by the preceding MAX_LFS_FILESIZE check through the branch profiling code. Consequently, min() cannot prove that the signed operand is nonnegative and rejects the mixed-signedness comparison:
min(outarg.size, ((loff_t)((long long)(~0ULL >> 1))) - pos) signedness error
This happens with GCC 8.1 on x86-64 and GCC 8.5 on arm and s390. GCC 8.1 remains the minimum supported compiler.
Use umin(), which is intended for comparing an unsigned value with a signed value that is known to be nonnegative. The preceding bounds check guarantees that MAX_LFS_FILESIZE - pos is nonnegative, and outarg.size bounds the result to unsigned int.
--- fs/fuse/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/notify.c +1 -1
@@ -155,7 +155,7 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, nodeid = outarg.nodeid; pos = outarg.offset; - num =min (outarg.size,MAX_LFS_FILESIZE - pos); + num =umin (outarg.size,MAX_LFS_FILESIZE - pos);down_read (&fc->killsb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 327/1257 ALSA: mpu401: shut down timer before freeing MPU
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9332af5220d42341bb1446a62c545c0518e990ef ]
When an MPU401 interface has no usable IRQ, the driver polls raw-MIDI input and output with a timer. During raw-MIDI teardown, the timer callback can already be running when snd_mpu401_uart_remove_timer() clears the last mode bit and calls timer_delete(). That API neither waits for a running callback nor prevents it from rearming the timer, and free_irq() does not synchronize timer callbacks. snd_mpu401_uart_free() can therefore release mpu while the timer callback still uses it.
Initialize the timer once when the MPU object is created and only rearm it while a timer mode is active. Shut it down synchronously after freeing the IRQ so an in-flight callback completes before mpu and its resources are released.
--- sound/drivers/mpu401/mpu401_uart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/drivers/mpu401/mpu401_uart.c +5 -3
@@ -155,20 +155,20 @@ static void snd_mpu401_uart_timer(struct timer_list *t) scoped_guard(spinlock_irqsave, &mpu->timer_lock) {/*mpu->mode |= MPU401_MODE_TIMER;*/ -mod_timer (&mpu->timer,1 + jiffies); +if (mpu->timer_invoked) +mod_timer (&mpu->timer,1 + jiffies); }if (mpu->rmidi)_snd_mpu401_uart_interrupt (mpu); }/* -* initialize the timer callback if not programmed yet +* arm the timer if it is not already active */ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu,int input) {guard (spinlock_irqsave)(&mpu->timer_lock);if (mpu->timer_invoked ==0 ) { -timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 );mod_timer (&mpu->timer,1 + jiffies); } mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER :
@@ -474,6 +474,7 @@ static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi)struct snd_mpu401 *mpu = rmidi->private_data;if (mpu->irq >=0 )free_irq (mpu->irq, (void *) mpu); +timer_shutdown_sync (&mpu->timer);release_and_free_resource (mpu->res);kfree (mpu); }
@@ -528,6 +529,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,spin_lock_init (&mpu->input_lock);spin_lock_init (&mpu->output_lock);spin_lock_init (&mpu->timer_lock); +timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 ); mpu->hardware = hardware; mpu->irq =-1 ; mpu->rmidi = rmidi;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 328/1257 ASoC: codecs: wcd9335: Fix SLIM interface device leak in wcd9335_slim_status()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 082723fee626532f176727b6438b666a96d5246c ]
of_slim_get_device() returns a device with an elevated reference count, and wcd->slim_ifc_dev is intentionally kept for the codec lifetime on success. However, all the failure paths of wcd9335_slim_status() return without dropping that reference, leaking the SLIM interface device whenever the register maps cannot be created or the codec fails to come up.
Put the device on each of those error paths.
--- sound/soc/codecs/wcd9335.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
sound/soc/codecs/wcd9335.c +10 -3
@@ -5135,25 +5135,32 @@ static int wcd9335_slim_status(struct slim_device *sdev,slim_get_logical_addr (wcd->slim_ifc_dev); wcd->regmap =regmap_init_slimbus (sdev, &wcd9335_regmap_config); -if (IS_ERR (wcd->regmap)) +if (IS_ERR (wcd->regmap)) { +put_device (&wcd->slim_ifc_dev->dev);return dev_err_probe (dev,PTR_ERR (wcd->regmap),"Failed to allocate slim register map\n" ); + } wcd->if_regmap =regmap_init_slimbus (wcd->slim_ifc_dev, &wcd9335_ifc_regmap_config); -if (IS_ERR (wcd->if_regmap)) +if (IS_ERR (wcd->if_regmap)) { +put_device (&wcd->slim_ifc_dev->dev);return dev_err_probe (dev,PTR_ERR (wcd->if_regmap),"Failed to allocate ifc register map\n" ); + } ret =wcd9335_bring_up (wcd);if (ret) {dev_err (dev,"Failed to bringup WCD9335\n" ); +put_device (&wcd->slim_ifc_dev->dev);return ret; } ret =wcd9335_irq_init (wcd); -if (ret) +if (ret) { +put_device (&wcd->slim_ifc_dev->dev);return ret; + }wcd9335_probe (wcd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 329/1257 iio: adc: ad4080: enable address ascension for chip identification
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
[ Upstream commit c051d08d98771132868abf0cb95b6de95ab3060a ]
The two byte bulk read at AD4080_REG_PRODUCT_ID_L expects PRODUCT_ID_L followed by PRODUCT_ID_H. After a software reset the AD408x defaults to descending address mode, so the second byte comes from CHIP_TYPE (0x03) instead. CHIP_TYPE reads 0x07 on all AD408x parts, so an AD4080 reports 0x0750 rather than 0x0050 and every part logs "Unrecognized CHIP_ID".
Set ADDR_ASC along with SDO_ENABLE before the read. This is the only multi byte transfer in the driver, so no other access is affected.
--- drivers/iio/adc/ad4080.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ad4080.c +2 -1
@@ -685,7 +685,8 @@ static int ad4080_setup_channel(struct ad4080_state *st, unsigned int ch)return ret; ret =regmap_write (st->regmap[ch],AD4080_REG_INTERFACE_CONFIG_A , -AD4080_INTERFACE_CONFIG_A_SDO_ENABLE ); +AD4080_INTERFACE_CONFIG_A_SDO_ENABLE | +AD4080_INTERFACE_CONFIG_A_ADDR_ASC );if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 330/1257 iio: amplifiers: ad8366: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit a3f438368c596040efbc44aa8a65e4e5ef2f3847 ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but ad8366_probe() later dereferences the result while setting up the IIO device.
Reject devices without match data before using the chip information.
--- drivers/iio/amplifiers/ad8366.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/amplifiers/ad8366.c +2 -0
@@ -326,6 +326,8 @@ static int ad8366_probe(struct spi_device *spi) st->spi = spi; st->info =spi_get_device_match_data (spi); +if (!st->info) +return -ENODATA ; enable_gpio =devm_gpiod_get_optional (dev,"enable" ,GPIOD_OUT_HIGH );if (IS_ERR (enable_gpio))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 331/1257 iio: dac: ad5755: validate SPI match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 85e2c8ca7ac9e39a61e7fb18728918f6e966f439 ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but ad5755_probe() stores and later dereferences the result.
Validate the match data before it is used.
--- drivers/iio/dac/ad5755.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/dac/ad5755.c +3 -0
@@ -819,6 +819,9 @@ static int ad5755_probe(struct spi_device *spi)spi_set_drvdata (spi, indio_dev); st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODATA ; + st->spi = spi; st->pwr_down =0xf ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/1257 iio: dac: mcp4821: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 6ac1faf4de61dcf27ffe8f2c25d96fe5f4b2886d ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but mcp4821_probe() dereferences the result while configuring the IIO device.
Reject devices without match data before using the chip information.
--- drivers/iio/dac/mcp4821.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/dac/mcp4821.c +5 -2
@@ -255,9 +255,13 @@ static const struct iio_info mcp4821_info = {static int mcp4821_probe (struct spi_device *spi) { +const struct mcp4821_chip_info *info;struct iio_dev *indio_dev;struct mcp4821_state *state; -const struct mcp4821_chip_info *info; + + info =spi_get_device_match_data (spi); +if (!info) +return -ENODATA ; indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*state));if (indio_dev ==NULL )
@@ -268,7 +272,6 @@ static int mcp4821_probe(struct spi_device *spi)/* default gain is 2x */ state->gain =2 ; - info =spi_get_device_match_data (spi); indio_dev->name = info->name; indio_dev->info = &mcp4821_info; indio_dev->modes =INDIO_DIRECT_MODE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/1257 iio: frequency: adf4377: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 2f3196d27e3bfcee0569d23a123aedcc6ddd39f1 ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but the result is later dereferenced by the property parsing and initialization paths.
Reject devices without match data before continuing probe.
--- drivers/iio/frequency/adf4377.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/frequency/adf4377.c +3 -0
@@ -1060,6 +1060,9 @@ static int adf4377_probe(struct spi_device *spi) st->regmap = regmap; st->spi = spi; st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODATA ; +mutex_init (&st->lock); ret =adf4377_properties_parse (st);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/1257 iio: imu: adis16400: validate SPI match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 2c01a0a1c5550b4f502c7747c06d2e57a240cd87 ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but adis16400_probe() immediately dereferences the result.
Validate the match data before it is used.
--- drivers/iio/imu/adis16400.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/imu/adis16400.c +3 -0
@@ -1150,6 +1150,9 @@ static int adis16400_probe(struct spi_device *spi)/* setup the industrialio driver allocated elements */ st->variant =spi_get_device_match_data (spi); +if (!st->variant) +return -ENODATA ; + indio_dev->name =spi_get_device_id (spi)->name; indio_dev->channels = st->variant->channels; indio_dev->num_channels = st->variant->num_channels;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/1257 iio: potentiometer: x9250: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit d13716e3defd5b8cec3ee2c27f4d9b7e01314067 ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but x9250_probe() later dereferences the result while naming the IIO device.
Reject devices without match data before enabling the regulators.
--- drivers/iio/potentiometer/x9250.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/potentiometer/x9250.c +6 -1
@@ -155,10 +155,15 @@ static const char *const x9250_regulator_names[] = {static int x9250_probe (struct spi_device *spi) { +const struct x9250_cfg *cfg;struct iio_dev *indio_dev;struct x9250 *x9250;int ret; + cfg =spi_get_device_match_data (spi); +if (!cfg) +return -ENODATA ; + ret =devm_regulator_bulk_get_enable (&spi->dev,ARRAY_SIZE (x9250_regulator_names), x9250_regulator_names);if (ret)
@@ -176,7 +181,7 @@ static int x9250_probe(struct spi_device *spi) x9250 =iio_priv (indio_dev); x9250->spi = spi; - x9250->cfg =spi_get_device_match_data (spi); + x9250->cfg = cfg; x9250->wp_gpio =devm_gpiod_get_optional (&spi->dev,"wp" ,GPIOD_OUT_LOW );if (IS_ERR (x9250->wp_gpio)) return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/1257 iio: pressure: bmp280: validate SPI match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 206fc54554c28d76c5d8f66091b846ef1dd88f64 ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but bmp280_spi_probe() immediately dereferences the result.
Validate the match data before selecting the regmap bus.
--- drivers/iio/pressure/bmp280-spi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/pressure/bmp280-spi.c +2 -0
@@ -83,6 +83,8 @@ static int bmp280_spi_probe(struct spi_device *spi)struct regmap *regmap; chip_info =spi_get_device_match_data (spi); +if (!chip_info) +return -ENODATA ;if (chip_info->spi_read_extra_byte) bmp_regmap_bus = &bmp380_regmap_bus;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/1257 iio: adc: ad7192: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 7f7a119a370ecf6c8d4ab9e9ee0a8cdd77afedd3 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
ad7192_probe() immediately dereferences the returned chip information to initialize the IIO device, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before using the chip information.
--- drivers/iio/adc/ad7192.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7192.c +3 -0
@@ -1406,6 +1406,9 @@ static int ad7192_probe(struct spi_device *spi) st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret /MILLI ; st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODATA ; + indio_dev->name = st->chip_info->name; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = st->chip_info->info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/1257 iio: adc: ad7606: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 7830650d5293a0f412a869225262ca51b661e49f ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
ad7606_spi_probe() dereferences the returned bus information to pass the chip information and bus operations to the core, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before entering the core.
--- drivers/iio/adc/ad7606_spi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7606_spi.c +5 -1
@@ -456,7 +456,11 @@ static const struct ad7606_bus_info ad7616_bus_info = {static int ad7606_spi_probe (struct spi_device *spi) { -const struct ad7606_bus_info *bus_info =spi_get_device_match_data (spi); +const struct ad7606_bus_info *bus_info; + + bus_info =spi_get_device_match_data (spi); +if (!bus_info) +return -ENODATA ;return ad7606_probe (&spi->dev, spi->irq,NULL , bus_info->chip_info, bus_info->bops);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/1257 iio: adc: ad7768-1: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit e29630bd463eb40e2e86fe45a565fb1d636ac822 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
ad7768_probe() later dereferences the returned chip information to initialize the IIO channels and device name, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before continuing the probe.
--- drivers/iio/adc/ad7768-1.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7768-1.c +3 -0
@@ -1829,6 +1829,9 @@ static int ad7768_probe(struct spi_device *spi) } st->chip =spi_get_device_match_data (spi); +if (!st->chip) +return -ENODATA ; + st->spi = spi; st->regmap =devm_regmap_init_spi (spi, &ad7768_regmap_config);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/1257 iio: adc: max11205: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit a07b5db685b2a3084240f9b4a9ee44f3b478c6e3 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
max11205_probe() immediately dereferences the returned chip information to set the IIO device name, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before using the chip information.
--- drivers/iio/adc/max11205.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/adc/max11205.c +2 -0
@@ -117,6 +117,8 @@ static int max11205_probe(struct spi_device *spi)ad_sd_init (&st->sd, indio_dev, spi, &max11205_sigma_delta_info); st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODATA ; indio_dev->name = st->chip_info->name; indio_dev->modes =INDIO_DIRECT_MODE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/1257 iio: adc: mcp3911: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit d3410a48d5eb9dd8238099cb0ee368d12005a385 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
mcp3911_probe() stores the result and later calls through chip->config and accesses other chip-specific fields, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before continuing the probe.
--- drivers/iio/adc/mcp3911.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/adc/mcp3911.c +2 -0
@@ -721,6 +721,8 @@ static int mcp3911_probe(struct spi_device *spi) adc =iio_priv (indio_dev); adc->spi = spi; adc->chip =spi_get_device_match_data (spi); +if (!adc->chip) +return -ENODATA ; ret =devm_regulator_get_enable_read_voltage (dev,"vref" );if (ret <0 && ret != -ENODEV )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/1257 iio: adc: ti-adc128s052: validate SPI match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 4ac257f2fd2a9cac00e748486fa003b4e1cc453e ]
SPI driver_override allows a device to bind to this driver without matching either the firmware tables or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
adc128_probe() also obtains the IIO device name by dereferencing the result of spi_get_device_id(), which is NULL on the same override path. The probe can therefore crash before it reaches the match data access.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data and use the always available SPI modalias for the IIO device name.
--- drivers/iio/adc/ti-adc128s052.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iio/adc/ti-adc128s052.c +5 -3
@@ -195,12 +195,14 @@ static int adc128_probe(struct spi_device *spi) adc =iio_priv (indio_dev); adc->spi = spi; - indio_dev->name =spi_get_device_id (spi)->name; + config =spi_get_device_match_data (spi); +if (!config) +return -ENODATA ; + + indio_dev->name = spi->modalias; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = &adc128_info; - config =spi_get_device_match_data (spi); - indio_dev->channels = config->channels; indio_dev->num_channels = config->num_channels;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/1257 iio: adc: ti-ads1018: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 156898c0f91aa731821d54fff910242f60b12e17 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
ads1018_spi_probe() immediately dereferences the returned chip information to initialize the IIO device, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before allocating the IIO device.
--- drivers/iio/adc/ti-ads1018.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads1018.c +5 -1
@@ -624,12 +624,16 @@ static int ads1018_trigger_setup(struct iio_dev *indio_dev)static int ads1018_spi_probe (struct spi_device *spi) { -const struct ads1018_chip_info *info =spi_get_device_match_data (spi); +const struct ads1018_chip_info *info;struct device *dev = &spi->dev;struct iio_dev *indio_dev;struct ads1018 *ads1018;int ret; + info =spi_get_device_match_data (spi); +if (!info) +return -ENODATA ; + indio_dev =devm_iio_device_alloc (dev,sizeof (*ads1018));if (!indio_dev)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/1257 iio: adc: ti-ads131m02: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9f0e96713033e5fe5a7a232e2c3aa994a8d2862f ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
ads131m_probe() immediately dereferences the returned configuration to initialize the IIO device, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before using the configuration.
--- drivers/iio/adc/ti-ads131m02.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/adc/ti-ads131m02.c +2 -0
@@ -897,6 +897,8 @@ static int ads131m_probe(struct spi_device *spi) indio_dev->info = &ads131m_info; config =spi_get_device_match_data (spi); +if (!config) +return -ENODATA ; priv->config = config; indio_dev->name = config->name;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/1257 iio: adc: ti-ads7950: validate SPI match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 6bdeaf23ef8062f4c38c025c50e524f1e4d59647 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
ti_ads7950_probe() also obtains the IIO device name by dereferencing the result of spi_get_device_id(), which is NULL on the same override path. The probe can therefore crash before dereferencing the chip information.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data and use the always available SPI modalias for the IIO device name.
--- drivers/iio/adc/ti-ads7950.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-ads7950.c +3 -1
@@ -527,8 +527,10 @@ static int ti_ads7950_probe(struct spi_device *spi) st->spi = spi; info =spi_get_device_match_data (spi); +if (!info) +return -ENODATA ; - indio_dev->name =spi_get_device_id (spi)->name; + indio_dev->name = spi->modalias; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->channels = info->channels; indio_dev->num_channels = info->num_channels;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/1257 iio: accel: adxl313: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit defd4c0b29f1cd17caa5feebac33fc5fdf4e1916 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
adxl313_spi_probe() dereferences chip_data to select the regmap configuration, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before selecting the configuration.
--- drivers/iio/accel/adxl313_spi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/accel/adxl313_spi.c +2 -0
@@ -79,6 +79,8 @@ static int adxl313_spi_probe(struct spi_device *spi)return ret; chip_data =spi_get_device_match_data (spi); +if (!chip_data) +return -ENODATA ; regmap =devm_regmap_init_spi (spi, &adxl31x_spi_regmap_config[chip_data->type]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/1257 iio: accel: adxl372: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit c72144098fa9205e9b1d08545e7d9b54a2e0aaf3 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
adxl372_spi_probe() passes the result to adxl372_probe(), which dereferences chip_info to set the IIO device name and capabilities, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data in the SPI frontend.
--- drivers/iio/accel/adxl372_spi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/accel/adxl372_spi.c +2 -0
@@ -25,6 +25,8 @@ static int adxl372_spi_probe(struct spi_device *spi)struct regmap *regmap; chip_info =spi_get_device_match_data (spi); +if (!chip_info) +return -ENODATA ; regmap =devm_regmap_init_spi (spi, &adxl372_spi_regmap_config);if (IS_ERR (regmap))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/1257 iio: accel: adxl380: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9f6d174e9fa5b265e7a0a6caa0c5b579bf899702 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
adxl380_spi_probe() passes the result to adxl380_probe(), which dereferences chip_info to set the IIO device name and operations, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data in the SPI frontend.
--- drivers/iio/accel/adxl380_spi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/accel/adxl380_spi.c +2 -0
@@ -25,6 +25,8 @@ static int adxl380_spi_probe(struct spi_device *spi)struct regmap *regmap; chip_data =spi_get_device_match_data (spi); +if (!chip_data) +return -ENODATA ; regmap =devm_regmap_init_spi (spi, &adxl380_spi_regmap_config);if (IS_ERR (regmap))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/1257 iio: accel: sca3000: reject devices without match data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit bee629c18a9389cfbbe182df954cf49a9066b383 ]
SPI driver_override allows a device to bind to this driver without matching either the OF or SPI device ID table. In that case, spi_get_device_match_data() returns NULL.
sca3000_probe() immediately dereferences the returned chip information to set the IIO device name and channel layout, causing a NULL pointer dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match data") fixed the same driver_override issue in another SPI driver. Reject devices without match data before using the chip information.
--- drivers/iio/accel/sca3000.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/accel/sca3000.c +2 -0
@@ -1462,6 +1462,8 @@ static int sca3000_probe(struct spi_device *spi) st->us = spi;mutex_init (&st->lock); st->info =spi_get_device_match_data (spi); +if (!st->info) +return -ENODATA ; indio_dev->name = st->info->name; indio_dev->info = &sca3000_info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/1257 iio: dac: mcp47feb02: Avoid unjustified probe error on missing label
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ariana Lazar <[email protected]>
[ Upstream commit bce5b7e29e72538ba61f76c6d534a58ab3838438 ]
Fix unjustified probe error on missing optional 'label' property by replacing dev_err_probe() with dev_warn_probe(). Correct %pfw usage by passing the child fwnode handle directly in the error message. Besides the probe warning a read error is returned at the attempt of reading a null label.
--- drivers/iio/dac/mcp47feb02.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/iio/dac/mcp47feb02.c +9 -5
@@ -921,7 +921,10 @@ static int mcp47feb02_read_label(struct iio_dev *indio_dev, struct iio_chan_spec {struct mcp47feb02_data *data =iio_priv (indio_dev); -return sysfs_emit (label,"%s\n" , data->labels[ch->address]); +if (data->labels[ch->address]) +return sysfs_emit (label,"%s\n" , data->labels[ch->address]); + +return -ENOENT ; }static const struct iio_info mcp47feb02_info = {
@@ -974,10 +977,11 @@ static int mcp47feb02_parse_fw(struct iio_dev *indio_dev,set_bit (reg, &data->active_channels_mask); - ret =fwnode_property_read_string (child,"label" , &data->labels[reg]); -if (ret) -return dev_err_probe (dev, ret,"%pfw: invalid label\n" , -fwnode_get_name (child)); +if (fwnode_property_present (child,"label" )) { + ret =fwnode_property_read_string (child,"label" , &data->labels[reg]); +if (ret) +dev_warn_probe (dev, ret,"%pfw: invalid label\n" , child); + } chanspec.address = reg; chanspec.channel = reg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/1257 iio: adc: stm32: fix minimum sampling time values
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheick Traore <[email protected]>
[ Upstream commit ef04fdc999ee40a58d513ea48d391c7dc78c908c ]
- On stm32mp15: vddcpu and vddq_ddr are not connected to internal channel, so their sampling time shouldn't be set.
- On stm32mp13: vddcpu and vddq_ddr are connected to internal channels and the value for vddcore was not correct. Values from the datasheet are 1us (e.g. 1000ns) for ts_vddcore, ts_vddcpu and ts_vddq_ddr.
--- drivers/iio/adc/stm32-adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/stm32-adc.c +2 -2
@@ -2734,7 +2734,7 @@ static const struct stm32_adc_cfg stm32h7_adc_cfg = { .set_ovs = stm32h7_adc_set_ovs, }; -static const unsigned int stm32_adc_min_ts_mp1[] = {100 ,100 ,100 ,4300 ,9800 }; +static const unsigned int stm32_adc_min_ts_mp1[] = {100 ,0 ,0 ,4300 ,9800 };static_assert (ARRAY_SIZE (stm32_adc_min_ts_mp1) ==STM32_ADC_INT_CH_NB );static const struct stm32_adc_cfg stm32mp1_adc_cfg = {
@@ -2756,7 +2756,7 @@ static const struct stm32_adc_cfg stm32mp1_adc_cfg = { .set_ovs = stm32h7_adc_set_ovs, }; -static const unsigned int stm32_adc_min_ts_mp13[] = {100 ,0 ,0 ,4300 ,9800 }; +static const unsigned int stm32_adc_min_ts_mp13[] = {1000 ,1000 ,1000 ,4300 ,9800 };static_assert (ARRAY_SIZE (stm32_adc_min_ts_mp13) ==STM32_ADC_INT_CH_NB );static const struct stm32_adc_cfg stm32mp13_adc_cfg = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/1257 iio: pressure: dps310: fix CFG_REG bit definitions
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rupesh Majhi <[email protected]>
[ Upstream commit 4334dc4092c271e6cd010c2ee70b7f4415c4c199 ]
Driver defines them as BIT(4), BIT(5) and BIT(6). Per datasheet P_SHIFT is bit 2, FIFO_EN is bit 1 and SPI_MODE is bit 0.
Only P_SHIFT has a user. dps310_set_pres_precision() sets it at oversampling 16 or above, so with wrong bit the result register is never shifted and stops matching the scale factor compensation divides by. in_pressure_input returns -ERANGE at oversampling 16, 32 and 64.
FIFO_EN needed by FIFO support later in this series.
--- drivers/iio/pressure/dps310.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/pressure/dps310.c +3 -3
@@ -50,9 +50,9 @@#define DPS310_CFG_REG 0x09#define DPS310_INT_HL BIT(7)#define DPS310_TMP_SHIFT_EN BIT(3) -#define DPS310_PRS_SHIFT_EN BIT(4) -#define DPS310_FIFO_EN BIT(5) -#define DPS310_SPI_EN BIT(6) +#define DPS310_PRS_SHIFT_EN BIT(2) +#define DPS310_FIFO_EN BIT(1) +#define DPS310_SPI_EN BIT(0)#define DPS310_RESET 0x0c#define DPS310_RESET_MAGIC 0x09#define DPS310_COEF_BASE 0x10
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/1257 spi: bcm2835: fix device_node reference leak in bcm2835_spi_setup()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Costa <[email protected]>
[ Upstream commit 8db44cca03df066186d6220bfad9fa482d7cdc13 ]
of_find_compatible_node() returns a device_node with its reference count incremented, but bcm2835_spi_setup() only uses the return value to test for a matching node in the loop and never releases it.
Declare the node with a scope-based __free(device_node) cleanup so the reference is dropped automatically when leaving the loop body, matching the existing __free(kfree) usage in the same function.
--- drivers/spi/spi-bcm2835.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm2835.c +3 -1
@@ -1297,7 +1297,9 @@ static int bcm2835_spi_setup(struct spi_device *spi) }for (i =0 ; i <ARRAY_SIZE (pinctrl_compats); i++) { -if (of_find_compatible_node (NULL ,NULL , pinctrl_compats[i])) + struct device_node *np __free(device_node) = +of_find_compatible_node (NULL ,NULL , pinctrl_compats[i]); +if (np)break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/1257 fs/ntfs3: fix integer overflow in find_log_rec() causing OOB read
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ibrahim Hashimov <[email protected]>
[ Upstream commit e2fcb0040b0b4097b2e97f3fbe77d3b66df9e816 ]
find_log_rec() validates the on-disk LFS_RECORD_HDR.client_data_len field (len, a raw u32 read straight from a mounted $LogFile page) against the log's total available space:
len = le32_to_cpu(rh->client_data_len);
rec_len = len + log->record_header_len;
if (rec_len >= log->total_avail)
return -EINVAL;The addition is unchecked. For len in [0xffffffd0, 0xffffffff] (i.e. log->record_header_len away from UINT_MAX), rec_len wraps to a small u32 value that trivially clears the rec_len >= log->total_avail guard, so a record whose declared length is actually ~4 GiB is reported as valid and in-page.
Because find_log_rec() wrongly accepts the record, its caller read_log_rec_lcb() hands it back to log_replay() as good. On the transaction-table replay leg, log_replay() re-derives the record length directly from the same raw, still-unclamped client_data_len field and uses it to size the restart-table blob:
rec_len = le32_to_cpu(frh->client_data_len); /* ~0xffffffff */
...
t16 = le16_to_cpu(lrh->redo_off);
rt = Add2Ptr(lrh, t16);
t32 = rec_len - t16; /* still ~4 GiB */
if (!check_rstbl(rt, t32))
return -EINVAL;check_rstbl()'s own bytes < ts bounds guard is defeated because the caller-supplied bytes (t32) is itself the poisoned ~4 GiB value, so the guard can never trigger. The subsequent entry-validation loop then walks rt->used (also attacker-controlled) entries of sizeof(struct RESTART_TABLE) == 0x18 bytes each straight past the end of the kmalloc(log->page_size) log-page buffer allocated in read_log_page(), producing an out-of-bounds read that is reachable simply by mounting a crafted $LogFile (no genuine dirty-page / crash-recovery state is required). Confirmed via KASAN as a slab-out-of-bounds read in check_rstbl(), called from log_replay() -> ntfs_loadlog_and_replay() -> ntfs_fill_super() -> mount(2).
Fix the root cause instead of hardening every downstream consumer of the poisoned length: make the addition in find_log_rec() overflow-safe with check_add_overflow(), mirroring the pattern fs/ntfs3/run.c already uses to validate other attacker-controlled on-disk length/offset arithmetic decoded from MAPPING_PAIRS runs, e.g.:
if (check_add_overflow(vcn64, len, &next_vcn))
return -EINVAL;
...
if (check_add_overflow(lcn, len, &lcn_end))
return -EINVAL;(fs/ntfs3/run.c, run_unpack()).
With the overflow rejected instead of silently wrapped, rec_len is only ever a true, non-wrapped sum, so the existing rec_len >= log->total_avail check now correctly rejects any oversized record up front. log_replay()'s transaction-table leg then never gets a chance to re-read the poisoned client_data_len, and check_rstbl() is never invoked with an attacker-inflated bytes for this path.
Verified on a v6.19 KASAN build: mounting a crafted $LogFile whose client_data_len overflows trips a KASAN slab-out-of-bounds-read report in check_rstbl() before this fix; with check_add_overflow() applied, the same image is cleanly rejected during log replay and no KASAN report fires.
--- fs/ntfs3/fslog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ntfs3/fslog.c +3 -1
@@ -7,6 +7,7 @@#include <linux/blkdev.h> #include <linux/fs.h> +#include <linux/overflow.h> #include <linux/random.h> #include <linux/slab.h>
@@ -2457,7 +2458,8 @@ static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb)* Check that the length field isn't greater than the total * available space the log file. */ - rec_len = len + log->record_header_len; +if (check_add_overflow (len, log->record_header_len, &rec_len)) +return -EINVAL ;if (rec_len >= log->total_avail)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/1257 fs/ntfs3: reject an oversized resident attribute on the inline iomap path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 456189f9c714dee6716c2a3aad908e63830cac66 ]
attr_data_get_block_locked() maps a resident attribute as a one-page IOMAP_INLINE extent: it allocates a single page, copies the resident value into it with memcpy(), and hands that page to ntfs_iomap_begin() as the inline data. The copy length is the on-disk resident value length (res.data_size), and mi_enum_attr() only bounds that length against the MFT record size. A corrupted volume with MFT records larger than a page can therefore present a resident $DATA whose length exceeds PAGE_SIZE, and the memcpy() then writes past the single destination page.
Impact: reading or writing a resident file on a mounted crafted NTFS volume whose MFT records are larger than a page overflows the one-page inline buffer in attr_data_get_block_locked() with attacker-controlled bytes.
Reject such an attribute in attr_data_get_block_locked(), before the page is allocated and the copy is made.
--- fs/ntfs3/attrib.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/ntfs3/attrib.c +15 -0
@@ -1034,6 +1034,21 @@ int attr_data_get_block_locked(struct ntfs_inode *ni, CLST vcn, CLST clen,if (!attr_b->non_res) {u32 data_size =le32_to_cpu (attr_b->res.data_size); + +/* +* A resident attribute is copied into a single page below +* (alloc_page() + memcpy()) and mapped as a one-page +* IOMAP_INLINE extent by ntfs_iomap_begin(). mi_enum_attr() +* only bounds the resident value length against the MFT record +* size, so a corrupted volume whose records are larger than a +* page can report data_size > PAGE_SIZE; copying that many bytes +* would overflow the single destination page. Reject it. +*/ +if (data_size >PAGE_SIZE ) { + err = -EINVAL ; + goto out; + } + *lcn =RESIDENT_LCN ; *len = data_size;if (res) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/1257 cxl/acpi: Check ACPI companion before use
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 371c2ad1624283b6c7a62a28199f5161d388a738 ]
Platform drivers can be forced to match devices outside their ID tables through driver_override. cxl_acpi_probe() assumes that every bound device has an ACPI companion and dereferences adev->dev.bus without checking the result of ACPI_COMPANION(). Force-binding cxl_acpi to a platform device without a companion therefore causes a NULL pointer dereference.
This was reproduced by setting the driver override for the pcspkr platform device to cxl_acpi and binding it through sysfs:
BUG: kernel NULL pointer dereference, address: 0000000000000280 #PF: supervisor read access in kernel mode RIP: cxl_acpi_probe+0xf4/0x220 Call Trace: platform_probe+0x4d/0x80 really_probe+0x106/0x370 device_driver_attach+0x4c/0xa0 bind_store+0xd0/0x100
Commit 2b3a5dabe89e ("platform/surface: acpi-notify: Check ACPI companion before use") fixed the same force-binding issue in another platform driver. Check the companion before setting up the CXL root and return -ENODEV when it is absent.
--- drivers/cxl/acpi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/cxl/acpi.c +7 -3
@@ -885,13 +885,17 @@ static int pair_cxl_resource(struct device *dev, void *data)static int cxl_acpi_probe (struct platform_device *pdev) { -int rc; +struct cxl_cfmws_context ctx; +struct acpi_device *adev;struct resource *cxl_res;struct cxl_root *cxl_root;struct cxl_port *root_port;struct device *host = &pdev->dev; -struct acpi_device *adev =ACPI_COMPANION (host); -struct cxl_cfmws_context ctx; +int rc; + + adev =ACPI_COMPANION (host); +if (!adev) +return -ENODEV ;device_lock_set_class (&pdev->dev, &cxl_root_key); rc = devm_add_action_or_reset(&pdev->dev, cxl_acpi_lock_reset_class,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/1257 ALSA: timer: Handle userspace-driven timer ioctls from 32-bit tasks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danish Khateeb <[email protected]>
[ Upstream commit 1bbc033983b76f41d51d4a48838bf94c5e6b6f50 ]
32-bit tasks on a 64-bit kernel can't use userspace-driven timers. The compat handler for /dev/snd/timer doesn't list SNDRV_TIMER_IOCTL_CREATE, so creating a timer fails with -ENOTTY. The file returned for a timer has no .compat_ioctl either, so SNDRV_TIMER_IOCTL_TRIGGER fails with -ENOTTY too.
struct snd_timer_uinfo has the same layout for 32-bit and 64-bit tasks, and SNDRV_TIMER_IOCTL_TRIGGER takes no argument, so both commands can be passed through unchanged.
The utimer selftest doesn't catch this when built with -m32: it takes -ENOTTY from SNDRV_TIMER_IOCTL_CREATE to mean CONFIG_SND_UTIMER=n and skips.
--- sound/core/timer.c | 1 + sound/core/timer_compat.c | 1 + 2 files changed, 2 insertions(+)
sound/core/timer.c +1 -0
@@ -2176,6 +2176,7 @@ static const struct file_operations snd_utimer_fops = { .llseek = noop_llseek, .release = snd_utimer_release, .unlocked_ioctl = snd_utimer_ioctl, + .compat_ioctl = snd_utimer_ioctl, };static int snd_utimer_start (struct snd_timer *t)
sound/core/timer_compat.c +1 -0
@@ -99,6 +99,7 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,case SNDRV_TIMER_IOCTL_PAUSE :case SNDRV_TIMER_IOCTL_PAUSE_OLD :case SNDRV_TIMER_IOCTL_NEXT_DEVICE : +case SNDRV_TIMER_IOCTL_CREATE :return __snd_timer_user_ioctl (file, cmd, (unsigned long )argp, true);case SNDRV_TIMER_IOCTL_GPARAMS32 :return snd_timer_user_gparams_compat (file, argp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/1257 media: qcom: camss: vfe-17x: Fix write master buffer done being dropped
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hitesh Patel <[email protected]>
[ Upstream commit eed550a8191c2f6984047a1b794b313d1bacf77d ]
The VFE 17x interrupt handler reads and clears the bus status registers on every interrupt, but only acts on the per write master BUF_DONE bits when bit 9 of IRQ_STATUS_0 is set as well. Bit 9 is the ping-pong flag of image master 1. It has nothing to do with the other write masters, and it is not guaranteed to be set in the same interrupt in which a write master reports a completed buffer.
The bus status is read-to-clear. When a buffer done arrives while bit 9 is not set, the handler clears the status and never calls wm_done() for it. The buffer stays queued in the driver and the video node never receives that frame.
With one RDI streaming this is rare. With two RDIs streaming on the same VFE, for instance two virtual channels demultiplexed by the CSID, the interrupt rate doubles and one of the two lines loses buffer done events continuously.
Act on the bus status alone, as the other gen2 VFE handlers do.
--- drivers/media/platform/qcom/camss/camss-vfe-17x.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-17x.c +2 -3
@@ -364,9 +364,8 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->isr_ops.comp_done (vfe, i);for (wm =0 ; wm <MSM_VFE_IMAGE_MASTERS_NUM ; wm++) -if (status0 &BIT (9 )) -if (vfe_bus_status[1 ] &STATUS1_WM_CLIENT_BUF_DONE (wm)) - vfe->isr_ops.wm_done (vfe, wm); +if (vfe_bus_status[1 ] &STATUS1_WM_CLIENT_BUF_DONE (wm)) + vfe->isr_ops.wm_done (vfe, wm);return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/1257 media: qcom: camss: vfe-17x: Fix write master selection for RDI lines
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hitesh Patel <[email protected]>
[ Upstream commit fc02156a3efb747b724a490cc50e1ad8c28a3b23 ]
On the gen2 VFE bus there is no crossbar between the RDI paths and the bus write masters: RDI n is served by write master n. The common vfe_get_output_v2() reflects this by mapping line->id to write master line->id, and every gen2 VFE except 17x uses it.
The 17x code kept its own vfe_get_output(), which reserves whichever write master is free first. That happens to be the right one as long as a single line streams and it is RDI0. As soon as two lines of the same VFE stream, for instance two virtual channels demultiplexed by the CSID to RDI0 and RDI1, the second line to start is given the write master of the other RDI. Both write masters are then programmed with the buffer address and frame size of the wrong line. The frames are truncated to the smaller of the two buffers and the SMMU faults on the larger one.
Use vfe_get_output_v2() on 17x like the other gen2 VFEs and drop the duplicate. This also removes an error path that released output->wm_idx[0] before it had been assigned.
The gen1 VFEs are not affected: they have a bus crossbar and any write master can serve any line, so vfe_reserve_wm() is correct there.
--- .../media/platform/qcom/camss/camss-vfe-17x.c | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-17x.c +1 -40
@@ -382,45 +382,6 @@ static int vfe_halt(struct vfe_device *vfe)return 0 ; } -static int vfe_get_output (struct vfe_line *line) -{ -struct vfe_device *vfe =to_vfe (line); -struct vfe_output *output; -unsigned long flags; -int wm_idx; - -spin_lock_irqsave (&vfe->output_lock, flags); - - output = &line->output; -if (output->state >VFE_OUTPUT_RESERVED ) { -dev_err (vfe->camss->dev,"Output is running\n" ); - goto error; - } - - output->wm_num =1 ; - - wm_idx =vfe_reserve_wm (vfe, line->id); -if (wm_idx <0 ) { -dev_err (vfe->camss->dev,"Can not reserve wm\n" ); - goto error_get_wm; - } - output->wm_idx[0 ] = wm_idx; - - output->drop_update_idx =0 ; - -spin_unlock_irqrestore (&vfe->output_lock, flags); - -return 0 ; - -error_get_wm: -vfe_release_wm (vfe, output->wm_idx[0 ]); - output->state =VFE_OUTPUT_OFF ; -error: -spin_unlock_irqrestore (&vfe->output_lock, flags); - -return -EINVAL ; -} -/* * vfe_enable - Enable streaming on VFE line * @line: VFE line
@@ -441,7 +402,7 @@ static int vfe_enable(struct vfe_line *line)mutex_unlock (&vfe->stream_lock); - ret =vfe_get_output (line); + ret =vfe_get_output_v2 (line);if (ret <0 ) goto error_get_output;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/1257 media: qcom: camss: vfe: Fix VFE reset while another line is streaming
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hitesh Patel <[email protected]>
[ Upstream commit e5d4b0e69a4017fd39354499c9d7583f625f0524 ]
vfe_disable_output() stops the write masters of the line being disabled and then resets the whole VFE. The reset is not limited to that line.
When two lines of one VFE stream at the same time, which is the case whenever a CSID demultiplexes several virtual channels to different RDIs, stopping the first line resets the VFE underneath the second line. The second line's write master configuration is wiped, the buffers it had in flight are never completed, and the VFE is left in a state in which the next global reset is not acknowledged. Stopping or restarting the second line then fails with:
VFE reset timeout
Move the reset to vfe_disable() and do it under stream_lock, as part of the decrement that makes the count reach zero, so that exactly one caller resets and no line can be enabled while the reset runs. Stopping the line's write masters is enough to quiesce that line on its own. With a single line streaming, the reset happens exactly as before.
--- drivers/media/platform/qcom/camss/camss-vfe.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe.c +5 -9
@@ -808,7 +808,7 @@ int vfe_put_output(struct vfe_line *line)return 0 ; } -static int vfe_disable_output (struct vfe_line *line) +static void vfe_disable_output (struct vfe_line *line) {struct vfe_device *vfe =to_vfe (line);struct vfe_output *output = &line->output;
@@ -820,8 +820,6 @@ static int vfe_disable_output(struct vfe_line *line) vfe->res->hw_ops->vfe_wm_stop (vfe, output->wm_idx[i]); output->gen2.active_num =0 ;spin_unlock_irqrestore (&vfe->output_lock, flags); - -return vfe_reset (vfe); }/*
@@ -833,21 +831,19 @@ static int vfe_disable_output(struct vfe_line *line)int vfe_disable (struct vfe_line *line) {struct vfe_device *vfe =to_vfe (line); -int ret; +int ret =0 ; - ret =vfe_disable_output (line); -if (ret) - goto error; +vfe_disable_output (line);vfe_put_output (line);mutex_lock (&vfe->stream_lock); - vfe->stream_count--; +if (--vfe->stream_count ==0 ) + ret =vfe_reset (vfe);mutex_unlock (&vfe->stream_lock); -error:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/1257 media: qcom: camss: Add "gcc_axi_hf" to 8775p VFE lite clock lists
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit 583b27edfe669fe27c631b4ac77c0ce0250f7bba ]
The "gcc_axi_hf" clock is correctly listed in the clock list of the 8775p 2 main VFE-s, but it is missing from all the VFE-lite clock lists, causing these to not work on platforms where the firmware allows turning off "gcc_axi_hf".
Add the missing "gcc_axi_hf" to fix the VFE-lite blocks not working on these platforms.
--- drivers/media/platform/qcom/camss/camss.c | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/media/platform/qcom/camss/camss.c +15 -10
@@ -4037,10 +4037,11 @@ static const struct camss_subdev_resources vfe_res_8775p[] = {/* VFE2 (lite) */ { .regulators = {}, - .clock = { "cpas_ahb", "cpas_vfe_lite", "vfe_lite_ahb", -"vfe_lite_csid" ,"vfe_lite_cphy_rx" , + .clock = { "cpas_ahb", "gcc_axi_hf", "cpas_vfe_lite", +"vfe_lite_ahb" ,"vfe_lite_csid" ,"vfe_lite_cphy_rx" , "vfe_lite", "camnoc_axi"}, .clock_rate = { + { 0 }, { 0 }, { 0 }, { 300000000, 400000000, 400000000, 400000000 },
@@ -4062,10 +4063,11 @@ static const struct camss_subdev_resources vfe_res_8775p[] = {/* VFE3 (lite) */ { .regulators = {}, - .clock = { "cpas_ahb", "cpas_vfe_lite", "vfe_lite_ahb", -"vfe_lite_csid" ,"vfe_lite_cphy_rx" , + .clock = { "cpas_ahb", "gcc_axi_hf", "cpas_vfe_lite", +"vfe_lite_ahb" ,"vfe_lite_csid" ,"vfe_lite_cphy_rx" , "vfe_lite", "camnoc_axi"}, .clock_rate = { + { 0 }, { 0 }, { 0 }, { 300000000, 400000000, 400000000, 400000000 },
@@ -4087,10 +4089,11 @@ static const struct camss_subdev_resources vfe_res_8775p[] = {/* VFE4 (lite) */ { .regulators = {}, - .clock = { "cpas_ahb", "cpas_vfe_lite", "vfe_lite_ahb", -"vfe_lite_csid" ,"vfe_lite_cphy_rx" , + .clock = { "cpas_ahb", "gcc_axi_hf", "cpas_vfe_lite", +"vfe_lite_ahb" ,"vfe_lite_csid" ,"vfe_lite_cphy_rx" , "vfe_lite", "camnoc_axi"}, .clock_rate = { + { 0 }, { 0 }, { 0 }, { 300000000, 400000000, 400000000, 400000000 },
@@ -4112,10 +4115,11 @@ static const struct camss_subdev_resources vfe_res_8775p[] = {/* VFE5 (lite) */ { .regulators = {}, - .clock = { "cpas_ahb", "cpas_vfe_lite", "vfe_lite_ahb", -"vfe_lite_csid" ,"vfe_lite_cphy_rx" , + .clock = { "cpas_ahb", "gcc_axi_hf", "cpas_vfe_lite", +"vfe_lite_ahb" ,"vfe_lite_csid" ,"vfe_lite_cphy_rx" , "vfe_lite", "camnoc_axi"}, .clock_rate = { + { 0 }, { 0 }, { 0 }, { 300000000, 400000000, 400000000, 400000000 },
@@ -4137,10 +4141,11 @@ static const struct camss_subdev_resources vfe_res_8775p[] = {/* VFE6 (lite) */ { .regulators = {}, - .clock = { "cpas_ahb", "cpas_vfe_lite", "vfe_lite_ahb", -"vfe_lite_csid" ,"vfe_lite_cphy_rx" , + .clock = { "cpas_ahb", "gcc_axi_hf", "cpas_vfe_lite", +"vfe_lite_ahb" ,"vfe_lite_csid" ,"vfe_lite_cphy_rx" , "vfe_lite", "camnoc_axi"}, .clock_rate = { + { 0 }, { 0 }, { 0 }, { 300000000, 400000000, 400000000, 400000000 },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/1257 media: venus: Fix iova allocation from restrict region
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Reddy <[email protected]>
[ Upstream commit 953439251b596cee039fbfeaffeb1d88a4b40f43 ]
The VPU issues DMA through several SMMU streams, and the hardware does not give every stream the same addressable range. The non-pixel stream cannot address the low 600MB of IOVA space, while the pixel stream can address the full range:
+-----------------------------------------------------------+
| non-pixel stream addressable range (600 MB - 3.5 GB) |
| 0x25800000 - 0xe0000000 |
+-----------------------------------------------------------+
| pixel stream addressable range (0 - 3.5 GB) |
| 0x00000000 - 0xe0000000 |
+-----------------------------------------------------------+A single "iommus" property on the video-codec node puts every stream in one IOMMU domain sharing one IOVA space, so nothing stops a non-pixel buffer from landing below 600MB. Once an allocation lands below that boundary the hardware faults, which shows up as unhandled SMMU page faults and spontaneous reboots.
https://gitlab.freedesktop.org/drm/msm/-/work_items/100
Fix this by reserving the 0-600MB range, below the boundary the non-pixel stream cannot address, using dma_iova_try_alloc() so the IOMMU-DMA core never hands that range out to a real DMA mapping. This reserves only IOVA space, it does not allocate any physical memory.
Since sub-nodes for non-pixel, pixel, and secure streams do not exist yet and only a single device is available, the restriction is applied to both non-pixel and pixel stream IDs.
--- drivers/media/platform/qcom/venus/core.c | 66 ++++++++++++++++++++++-- drivers/media/platform/qcom/venus/core.h | 6 +++ 2 files changed, 69 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/core.c +63 -3
@@ -377,6 +377,57 @@ static int venus_add_dynamic_nodes(struct venus_core *core)static void venus_remove_dynamic_nodes (struct venus_core *core) {}#endif +static void venus_unreserve_iova_region (struct device *dev,struct dma_iova_state *state) +{ +unsigned int i; + +for (i =0 ;dma_iova_size (&state[i]); i++) +dma_iova_free (dev, &state[i]); +} + +static int venus_reserve_iova_region (struct device *dev,struct dma_iova_state **iova_state, +unsigned long start,unsigned long size) +{ +unsigned long dma_limit = dev->bus_dma_limit; +unsigned long end, rem, chunk; +struct dma_iova_state *state; +unsigned int count =0 ; +int ret = -ENOMEM ; + + state =devm_kcalloc (dev,BITS_PER_TYPE (dma_addr_t) +1 ,sizeof (*state),GFP_KERNEL ); +if (!state) +return ret; + + end = start + size; + rem = end -max (start,PAGE_SIZE ); + dev->bus_dma_limit = end -1 ; + +while (rem) { + chunk =min (end & -end, (u64 )1 << (fls64 (rem) -1 )); + +if (!dma_iova_try_alloc (dev, &state[count],0 , chunk)) + goto err_free_iova; + +if (state[count].addr != end - chunk || state[count].__size != chunk) + goto err_free_iova; + + rem -= chunk; + end -= chunk; + count++; + } + + *iova_state = state; + dev->bus_dma_limit = dma_limit; + +return 0 ; + +err_free_iova: +venus_unreserve_iova_region (dev, state); + dev->bus_dma_limit = dma_limit; + +return ret; +} +static int venus_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -421,10 +472,15 @@ static int venus_probe(struct platform_device *pdev)return ret; } - ret =dma_set_mask_and_coherent (dev, core->res->dma_mask); + ret =venus_reserve_iova_region (dev, &core->iova_state,VENUS_NP_RESERVE_IOVA_START , +VENUS_NP_RESERVE_IOVA_SIZE );if (ret) goto err_core_put; + ret =dma_set_mask_and_coherent (dev, core->res->dma_mask); +if (ret) + goto err_unresv_iova_region; +dma_set_max_seg_size (dev,UINT_MAX );INIT_LIST_HEAD (&core->instances);
@@ -434,13 +490,13 @@ static int venus_probe(struct platform_device *pdev) ret =hfi_create (core, &venus_core_ops);if (ret) - goto err_core_put; + goto err_unresv_iova_region; ret =devm_request_threaded_irq (dev, core->irq, hfi_isr, venus_isr_thread,IRQF_TRIGGER_HIGH |IRQF_ONESHOT ,"venus" , core);if (ret) - goto err_core_put; + goto err_unresv_iova_region;venus_assign_register_offsets (core);
@@ -525,6 +581,8 @@ static int venus_probe(struct platform_device *pdev)v4l2_device_unregister (&core->v4l2_dev); err_hfi_destroy:hfi_destroy (core); +err_unresv_iova_region: +venus_unreserve_iova_region (dev, core->iova_state); err_core_put:if (core->pm_ops->core_put) core->pm_ops->core_put (core);
@@ -562,6 +620,8 @@ static void venus_remove(struct platform_device *pdev)hfi_destroy (core); +venus_unreserve_iova_region (dev, core->iova_state); +mutex_destroy (&core->pm_lock);mutex_destroy (&core->lock);venus_dbgfs_deinit (core);
drivers/media/platform/qcom/venus/core.h +6 -0
@@ -8,6 +8,7 @@#define __VENUS_CORE_H_#include <linux/bitops.h> +#include <linux/dma-mapping.h> #include <linux/list.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h>
@@ -30,6 +31,9 @@#define VENUS_MAX_FPS 240 +#define VENUS_NP_RESERVE_IOVA_START 0x0 +#define VENUS_NP_RESERVE_IOVA_SIZE 0x25800000 +extern int venus_fw_debug;struct freq_tbl {
@@ -189,6 +193,7 @@ struct venus_format {* @dump_core: a flag indicating that a core dump is required * @ocs: OF changeset pointer * @hwmode_dev: a flag indicating that HW_CTRL_TRIGGER is used in clock driver +* @iova_state: a pointer to an array of dma_iova_state entries reserved for restricted IOVA region */ struct venus_core {void __iomem *base;
@@ -250,6 +255,7 @@ struct venus_core {unsigned long dump_core;struct of_changeset *ocs;bool hwmode_dev; +struct dma_iova_state *iova_state; };struct vdec_controls {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/1257 media: iris: reset AHB bridge before enabling HW mode
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
[ Upstream commit cc330f5589965bcf99307ee9c66deb8a0a53e0ee ]
When video power domain is switched from software-controlled mode to hardware-controlled mode, the core may be powered down without the AHB bridge going through the required reset sequence. This may leave the bridge FIFO in a stale state.
Reset the CPU-to-VPU AHB bridge before switching the power domain to hardware-controlled mode. This ensures that the bridge FIFO are in reset state before going for mode switch.
--- drivers/media/platform/qcom/iris/iris_vpu_common.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/platform/qcom/iris/iris_vpu_common.c +5 -0
@@ -311,6 +311,11 @@ int iris_vpu_power_on_hw(struct iris_core *core)int iris_vpu_set_hwmode (struct iris_core *core) { +writel (CORE_BRIDGE_SW_RESET |CORE_BRIDGE_HW_RESET_DISABLE , + core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (CORE_BRIDGE_HW_RESET_DISABLE , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +writel (0x0 , core->reg_base +CPU_CS_AHB_BRIDGE_SYNC_RESET ); +return dev_pm_genpd_set_hwmode (core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ], true); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/1257 media: iris: avoid bit depth validation for capture formats
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Reddy <[email protected]>
[ Upstream commit 40e9c3b3e35c6d65a3a0d3b1483716ad48b046bd ]
When validating a capture format, check_format() compares the requested pixel format against inst->fw_caps[BIT_DEPTH]. However, the bit depth capability is not available at this stage and it contains the default value of BIT_DEPTH_8. The actual bit depth is updated later after the firmware reports stream capabilities through read_input_subcr_params(). Because of this, a valid client request of QC10C format request is rejected during the initial format negotiation. The driver then falls back to the default capture format (NV12) and stores it as capture format. Later, when the firmware reports that the stream is 10-bit, the driver sees NV12 as the selected capture format and switches to the default 10-bit format (P010). As a result, the original QC10C format requested by userspace is lost and QC10C decoding cannot work correctly. The bit depth information is not reliable during the initial format setup, so it should not be used to validate capture formats. Remove the bit-depth checks from check_format() and only verify that the requested pixel format is supported. This allows the format requested by userspace is handled correctly.
--- drivers/media/platform/qcom/iris/iris_vdec.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/media/platform/qcom/iris/iris_vdec.c +0 -10
@@ -95,16 +95,6 @@ static bool check_format(struct iris_inst *inst, u32 pixfmt, u32 type)if (i == size)return false; -if (type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { -if (iris_fmt_is_8bit (pixfmt) && - inst->fw_caps[BIT_DEPTH ].value ==BIT_DEPTH_10 ) -return false; - -if (iris_fmt_is_10bit (pixfmt) && - inst->fw_caps[BIT_DEPTH ].value !=BIT_DEPTH_10 ) -return false; - } -return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/1257 media: iris: Fix iova allocation from restrict region
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Reddy <[email protected]>
[ Upstream commit 200473c198b201c308dfb916fb3233074d9407fa ]
The VPU issues DMA through several SMMU streams, and the hardware does not give every stream the same addressable range. The non-pixel stream cannot address the low 600MB of IOVA space, while the pixel stream can address the full range:
+-----------------------------------------------------------+
| non-pixel stream addressable range (600 MB - 3.5 GB) |
| 0x25800000 - 0xe0000000 |
+-----------------------------------------------------------+
| pixel stream addressable range (0 - 3.5 GB) |
| 0x00000000 - 0xe0000000 |
+-----------------------------------------------------------+A single "iommus" property on the video-codec node puts every stream in one IOMMU domain sharing one IOVA space, so nothing stops a non-pixel buffer from landing below 600MB. Once an allocation lands below that boundary the hardware faults, which shows up as unhandled SMMU page faults and spontaneous reboots.
https://gitlab.freedesktop.org/drm/msm/-/work_items/100
Fix this by reserving the 0-600MB range, below the boundary the non-pixel stream cannot address, using dma_iova_try_alloc() so the IOMMU-DMA core never hands that range out to a real DMA mapping. This reserves only IOVA space, it does not allocate any physical memory.
Since sub-nodes for non-pixel, pixel, and secure streams do not exist yet and only a single device is available, the restriction is applied to both non-pixel and pixel stream IDs.
--- drivers/media/platform/qcom/iris/iris_core.h | 6 ++ drivers/media/platform/qcom/iris/iris_probe.c | 62 ++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_core.h +6 -0
@@ -7,6 +7,7 @@#define __IRIS_CORE_H__#include <linux/types.h> +#include <linux/dma-mapping.h> #include <linux/pm_domain.h> #include <media/v4l2-device.h>
@@ -25,6 +26,9 @@ struct icc_info {#define IRIS_FW_VERSION_LENGTH 128#define IFACEQ_CORE_PKT_SIZE (1024 * 4) +#define IRIS_NP_RESERVE_IOVA_START 0x0 +#define IRIS_NP_RESERVE_IOVA_SIZE 0x25800000 +enum domain_type {ENCODER =BIT (0 ),DECODER =BIT (1 ),
@@ -77,6 +81,7 @@ struct qcom_ubwc_cfg_data;* @instances: a list_head of all instances * @inst_fw_caps_dec: an array of supported instance capabilities by decoder * @inst_fw_caps_enc: an array of supported instance capabilities by encoder +* @iova_state: a pointer to an array of dma_iova_state entries reserved for restricted IOVA region */ struct iris_core {
@@ -123,6 +128,7 @@ struct iris_core {/* encoder and decoder have overlapping caps, so two different arrays are required */ struct platform_inst_fw_cap inst_fw_caps_dec[INST_FW_CAP_MAX ];struct platform_inst_fw_cap inst_fw_caps_enc[INST_FW_CAP_MAX ]; +struct dma_iova_state *iova_state; };int iris_core_init (struct iris_core *core);
drivers/media/platform/qcom/iris/iris_probe.c +61 -1
89 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/1257 media: iris: Fix bus_info prefix in VIDIOC_QUERYCAP
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Reddy <[email protected]>
[ Upstream commit 1facae9bc3c1cfcabc77184754d64c349831cbc5 ]
The bus_info field returned by VIDIOC_QUERYCAP used the abbreviated prefix "plat:" instead of the standard "platform:" prefix expected for platform devices. v4l2-compliance validates that bus_info for platform devices starts with "platform:", and fails otherwise:
fail: ../utils/v4l2-compliance/v4l2-compliance.cpp(671):
missing bus_info prefix ('plat:aa00000.video-codec:dec')
Update the format string in iris_querycap() to use "platform:" so that v4l2-compliance bus_info check passes.
--- drivers/media/platform/qcom/iris/iris_vidc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_vidc.c +1 -1
@@ -466,7 +466,7 @@ static int iris_querycap(struct file *filp, void *fh, struct v4l2_capability *ca info ="enc" ; }snprintf (cap->bus_info,sizeof (cap->bus_info), -"plat:%s:%s" ,dev_name (core->dev), info); +"platform:%s:%s" ,dev_name (core->dev), info);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/1257 media: iris: Fix power-off ordering to disable power domain after clocks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Reddy <[email protected]>
[ Upstream commit 9cfae7726a9a9f526e8905dbddde355be2674e3d ]
In iris_vpu_power_off_hw(), iris_disable_power_domains() was called before the associated clocks (IRIS_BSE_HW_CLK, IRIS_HW_AHB_CLK, IRIS_HW_CLK) were disabled and unprepared. This reverses the correct power-down sequence: with the power domain already removed, the subsequent clk_disable_unprepare() calls end up operating on clock-controller hardware that is no longer powered, which can hang or behave unpredictably.
Reorder the calls so iris_disable_power_domains() runs after all three clocks are disabled, ensuring clocks are always turned off while their power domain is still active, and mirroring the reverse of the power-on sequence.
--- drivers/media/platform/qcom/iris/iris_vpu_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_vpu_common.c +1 -1
@@ -223,10 +223,10 @@ int iris_vpu_power_off_controller(struct iris_core *core)void iris_vpu_power_off_hw (struct iris_core *core) {dev_pm_genpd_set_hwmode (core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ], false); -iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]);iris_disable_unprepare_clock (core,IRIS_BSE_HW_CLK );iris_disable_unprepare_clock (core,IRIS_HW_AHB_CLK );iris_disable_unprepare_clock (core,IRIS_HW_CLK ); +iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); }void iris_vpu_power_off (struct iris_core *core)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/1257 media: iris: Fix frame interval enumeration for non-divisor framerates
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Reddy <[email protected]>
[ Upstream commit 3ad393b701dd99274f09403185f71ec7a93135bd ]
iris_enum_frameintervals() advertised frame intervals using V4L2_FRMIVAL_TYPE_STEPWISE with step=1/MAXIMUM_FPS where MAXIMUM_FPS is 480. This caused client to enumerate only framerates of the form MAXIMUM_FPS/n (where n is a positive integer), restricting support to exact divisors of MAXIMUM_FPS (e.g., 480, 240, 160, 120, 96, 80, 60, 30, 24, 1).
Framerates that are not exact divisors of MAXIMUM_FPS, such as 29 fps, 25 fps, were excluded from the enumerated list. There is no hardware restriction to framerates that are exact divisors of MAXIMUM_FPS. This caused GStreamer caps negotiation to fail with an "internal data stream error" when encoding content at such framerates.
Fix this by using V4L2_FRMIVAL_TYPE_CONTINUOUS. With CONTINUOUS type, GStreamer creates a continuous framerate range [1, max_fps], allowing any integer framerate within the range to pass caps negotiation. The step field is set to 1/1 as required by the V4L2 specification for continuous frame intervals.
--- drivers/media/platform/qcom/iris/iris_vidc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_vidc.c +2 -2
@@ -438,14 +438,14 @@ static int iris_enum_frameintervals(struct file *filp, void *fh, mbpf =NUM_MBS_PER_FRAME (fival->height, fival->width); fps =DIV_ROUND_UP (core->iris_platform_data->max_core_mbps, mbpf); - fival->type =V4L2_FRMIVAL_TYPE_STEPWISE ; + fival->type =V4L2_FRMIVAL_TYPE_CONTINUOUS ; fival->stepwise.min.numerator =1 ; fival->stepwise.min.denominator =min_t (u32, fps,MAXIMUM_FPS ); fival->stepwise.max.numerator =1 ; fival->stepwise.max.denominator =1 ; fival->stepwise.step.numerator =1 ; - fival->stepwise.step.denominator =MAXIMUM_FPS ; + fival->stepwise.step.denominator =1 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 369/1257 ALSA: sgio2audio: Only free successfully requested IRQs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit af3d225b639c6f9fb8fd5e1e27f11672d56724b6 ]
snd_sgio2audio_create() calls snd_sgio2audio_free() when an IRQ request fails. The cleanup helper currently walks the complete IRQ table, including entries whose request_irq() calls have not been attempted yet. free_irq() then receives an IRQ and dev_id pair that was never registered.
Pass the number of successfully requested IRQs to the cleanup helper on the request failure path, while retaining the full-table cleanup for teardown after all requests have succeeded.
--- sound/mips/sgio2audio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
sound/mips/sgio2audio.c +7 -6
@@ -742,7 +742,8 @@ static struct {/* ALSA driver */ -static int snd_sgio2audio_free (struct snd_sgio2audio *chip) +static int snd_sgio2audio_free (struct snd_sgio2audio *chip, +unsigned int irq_count) {int i;
@@ -752,7 +753,7 @@ static int snd_sgio2audio_free(struct snd_sgio2audio *chip)writeq (0 , &mace->perif.audio.control);/* release IRQ's */ -for (i =0 ; i <ARRAY_SIZE (snd_sgio2_isr_table); i++) +for (i =0 ; i < irq_count; i++)free_irq (snd_sgio2_isr_table[i].irq, &chip->channel[snd_sgio2_isr_table[i].idx]);
@@ -768,7 +769,7 @@ static int snd_sgio2audio_dev_free(struct snd_device *device) {struct snd_sgio2audio *chip = device->device_data; -return snd_sgio2audio_free (chip); +return snd_sgio2audio_free (chip,ARRAY_SIZE (snd_sgio2_isr_table)); }static const struct snd_device_ops ops = {
@@ -819,7 +820,7 @@ static int snd_sgio2audio_create(struct snd_card *card, 0, snd_sgio2_isr_table[i].desc, &chip->channel[snd_sgio2_isr_table[i].idx])) { -snd_sgio2audio_free (chip); +snd_sgio2audio_free (chip, i);printk (KERN_ERR "sgio2audio: cannot allocate irq %d\n" , snd_sgio2_isr_table[i].irq);return -EBUSY ;
@@ -843,13 +844,13 @@ static int snd_sgio2audio_create(struct snd_card *card,/* initialize the AD1843 codec */ err =ad1843_init (&chip->ad1843);if (err <0 ) { -snd_sgio2audio_free (chip); +snd_sgio2audio_free (chip,ARRAY_SIZE (snd_sgio2_isr_table));return err; } err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops);if (err <0 ) { -snd_sgio2audio_free (chip); +snd_sgio2audio_free (chip,ARRAY_SIZE (snd_sgio2_isr_table));return err; } *rchip = chip;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/1257 m68k: dmasound: Keep the Q40 IRQ handler registered
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit fa2e77ac5bf81a60864e71fc72196227692d7162 ]
Q40PlayNextFrame() re-registers the sample IRQ after stopping it. This function can be called with dmasound.lock held and from the sample IRQ handler, so free_irq() and request_irq() can sleep or deadlock. A failed re-registration can also leave playback without an IRQ.
Register one handler for the lifetime of the driver and select mono or stereo sample handling inside that handler. Call the frame completion path after releasing dmasound.lock so it can refill the queue safely.
--- sound/oss/dmasound/dmasound_q40.c | 65 ++++++++++++++----------------- 1 file changed, 29 insertions(+), 36 deletions(-)
sound/oss/dmasound/dmasound_q40.c +29 -36
@@ -49,9 +49,8 @@ static int Q40SetFormat(int format);static int Q40SetVolume (int volume);static void Q40PlayNextFrame (int index);static void Q40Play (void ); -static irqreturn_t Q40StereoInterrupt (int irq,void *dummy); -static irqreturn_t Q40MonoInterrupt (int irq,void *dummy); -static void Q40Interrupt (void ); +static irqreturn_t q40_audio_interrupt (int irq,void *dummy); +static void q40_frame_done (void );/*** Mid level stuff *********************************************************/
@@ -372,8 +371,8 @@ static void Q40Free(void *ptr, unsigned int size)static int __init Q40IrqInit (void ) {/* Register interrupt handler. */ -if (request_irq (Q40_IRQ_SAMPLE , Q40StereoInterrupt,0 , -"DMA sound" , Q40Interrupt)) +if (request_irq (Q40_IRQ_SAMPLE , q40_audio_interrupt,0 , +"DMA sound" , q40_frame_done))return 0 ;return (1 );
@@ -384,7 +383,7 @@ static int __init Q40IrqInit(void)static void Q40IrqCleanUp (void ) {master_outb (0 ,SAMPLE_ENABLE_REG ); -free_irq (Q40_IRQ_SAMPLE , Q40Interrupt); +free_irq (Q40_IRQ_SAMPLE , q40_frame_done); }#endif /* MODULE */
@@ -403,7 +402,6 @@ static void Q40PlayNextFrame(int index)u_char *start;u_long size;u_char speed; -int error;/* used by Q40Play() if all doubts whether there really is something * to be played are already wiped out.
@@ -420,15 +418,6 @@ static void Q40PlayNextFrame(int index) speed=(dmasound.hard.speed==10000 ?0 :1 );master_outb (0 ,SAMPLE_ENABLE_REG ); -free_irq (Q40_IRQ_SAMPLE , Q40Interrupt); -if (dmasound.soft.stereo) - error =request_irq (Q40_IRQ_SAMPLE , Q40StereoInterrupt,0 , -"Q40 sound" , Q40Interrupt); -else - error =request_irq (Q40_IRQ_SAMPLE , Q40MonoInterrupt,0 , -"Q40 sound" , Q40Interrupt); -if (error &&printk_ratelimit ()) -pr_err ("Couldn't register sound interrupt\n" );master_outb ( speed,SAMPLE_RATE_REG );master_outb (1 ,SAMPLE_CLEAR_REG );
@@ -456,31 +445,35 @@ static void Q40Play(void)spin_unlock_irqrestore (&dmasound.lock, flags); } -static irqreturn_t Q40StereoInterrupt (int irq,void *dummy) -{ -spin_lock (&dmasound.lock); -if (q40_sc>1 ){ - *DAC_LEFT =*q40_pp++; - *DAC_RIGHT =*q40_pp++; - q40_sc -=2 ; -master_outb (1 ,SAMPLE_CLEAR_REG ); - }else Q40Interrupt (); -spin_unlock (&dmasound.lock); -return IRQ_HANDLED ; -} -static irqreturn_t Q40MonoInterrupt (int irq,void *dummy) +static irqreturn_t q40_audio_interrupt (int irq,void *dummy) { +bool frame_done = false; +spin_lock (&dmasound.lock); -if (q40_sc>0 ){ - *DAC_LEFT =*q40_pp; - *DAC_RIGHT =*q40_pp++; - q40_sc --; -master_outb (1 ,SAMPLE_CLEAR_REG ); - }else Q40Interrupt (); +if (dmasound.hard.stereo) { +if (q40_sc >1 ) { + *DAC_LEFT = *q40_pp++; + *DAC_RIGHT = *q40_pp++; + q40_sc -=2 ; +master_outb (1 ,SAMPLE_CLEAR_REG ); + }else { + frame_done = true; + } + }else if (q40_sc >0 ) { + *DAC_LEFT = *q40_pp; + *DAC_RIGHT = *q40_pp++; + q40_sc--; +master_outb (1 ,SAMPLE_CLEAR_REG ); + }else { + frame_done = true; + }spin_unlock (&dmasound.lock); +if (frame_done) +q40_frame_done ();return IRQ_HANDLED ; } -static void Q40Interrupt (void ) + +static void q40_frame_done (void ) {if (!write_sq.active) {/* playing was interrupted and sq_reset() has already cleared
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 371/1257 ALSA: core: Check shutdown flag at D0 power-state, too
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit ad63c5b62843895e8c3cd7291ed07cc659df0355 ]
The snd_power_ref_and_wait() skips the card->shutdown check when the card is already in D0 state and immediately returns as successful, by assuming the all-green in D0. This assumption makes the code after this sync point behaving as if all power is up and ready, even though actually it might have been already at the disconnected state.
Add the missing check of shutdown flag there for the more consistent behavior.
--- sound/core/init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/core/init.c +6 -6
@@ -1174,12 +1174,12 @@ EXPORT_SYMBOL(snd_card_file_remove);int snd_power_ref_and_wait (struct snd_card *card) {snd_power_ref (card); -if (snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 ) -return 0 ; -wait_event_cmd (card->power_sleep, - card->shutdown || -snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , -snd_power_unref (card),snd_power_ref (card)); +if (snd_power_get_state (card) !=SNDRV_CTL_POWER_D0 ) { +wait_event_cmd (card->power_sleep, + card->shutdown || +snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , +snd_power_unref (card),snd_power_ref (card)); + }if (card->shutdown) {snd_power_unref (card);return -ENODEV ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 372/1257 clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 1c4f9480473917558908c083d1293b4ebb3d50c5 ]
In jh7110_ispcrg_probe(), the error path for pm_runtime_get_sync() failure directly returns without releasing the runtime PM reference count. The call to __pm_runtime_resume() increments the usage count unconditionally before attempting to resume, and does not decrement it on failure. Thus the leaked reference makes it impossible to suspend the device later.
All other error paths correctly jump to err_exit and call pm_runtime_put_sync(). Fix this by replacing pm_runtime_get_sync() with pm_runtime_resume_and_get(), which properly balances the reference count on error.
--- drivers/clk/starfive/clk-starfive-jh7110-isp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/starfive/clk-starfive-jh7110-isp.c +1 -1
@@ -130,7 +130,7 @@ static int jh7110_ispcrg_probe(struct platform_device *pdev)/* enable power domain and clocks */ pm_runtime_enable (priv->dev); - ret =pm_runtime_get_sync (priv->dev); + ret =pm_runtime_resume_and_get (priv->dev);if (ret <0 )return dev_err_probe (priv->dev, ret,"failed to turn on power\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 373/1257 powerpc64/bpf: fix percpu private stack leak on JIT failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Dubey <[email protected]>
[ Upstream commit 24affb84d98e6b37b276aa57e5dd25ad93458cea ]
The existing conditional statement in bpf_int_jit_compile() frees the percpu private stack at out_addrs only when the image buffer was never allocated.
If bpf_jit_build_body() fails during a code-generation pass, the image buffer has already been allocated, so !image is false and the percpu stack is not freed.
Because JIT compilation failed, fp->jited remains at 0. The subsequent bpf_jit_free() path only frees priv_stack_ptr when fp->jited is set, so freeing is skipped here too, leaking the percpu allocation.
Fix implements freeing the private stack whenever fp->jited was not set, i.e. compilation did not succeed, instead of keying off !image. !fp->jited already covers the !image case, since image is only NULL on early-failure paths where fp->jited is likewise 0.
--- arch/powerpc/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp.c +1 -1
@@ -357,7 +357,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr (void *)fimage + FUNCTION_DESCR_SIZE); out_addrs: -if (!image && priv_stack_ptr) { +if (!fp->jited && priv_stack_ptr) { fp->aux->priv_stack_ptr =NULL ;free_percpu (priv_stack_ptr); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 374/1257 powerpc/bpf: fix buffer overflow in JIT for large BPF programs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Dubey <[email protected]>
[ Upstream commit 78ce55b7913a78e1687306668e078b86bc6508ee ]
During size calculation in pass-0, exit_addr is 0 since addrs[fp->len] is not yet populated. bpf_jit_emit_exit_insn() treats a zero exit_addr as in-range and skips bpf_jit_build_epilogue(), so the alternate inline epilogue instructions are not counted in alloclen.
In later passes, if the real exit_addr falls outside the 32MB branch range, the full inline epilogue is emitted into the already-allocated buffer, writing past its end and corrupting adjacent memory.
Fix by ensuring exit_addr is non-zero before treating it as in-range, so pass-0 always falls through to bpf_jit_build_epilogue() and conservatively accounts for all epilogue instructions in alloclen. Also range check alt_exit_addr directly in the else-if condition.
Since exit_addr handling now falls through to the epilogue, two related issues in bpf_int_jit_compile() must also be addressed:
1. Reset cgctx.alt_exit_addr before the second size-calculation pass. Without this, a stale alt_exit_addr from the first pass causes the second pass to emit a single jump instead of the full epilogue, undercounting alloclen and reintroducing the overflow.
2. Recompute addrs[fp->len] at the end of each code-generation pass. The larger pass-0 body can shrink in later passes as out-of-range exits settle into in-range jumps; a stale addrs[fp->len] would leave exit branches targeting past the real (shrunken) epilogue.
Because shrinkage in a later pass can move the epilogue offset, the fixed two-pass loop is no longer sufficient: an exit that was out of range in an earlier pass may fall in range once the epilogue offset shrinks, shrinking the body further and overwriting the start of the epilogue. Convert the code-generation loop to iterate until the program size converges, bounded by CODEGEN_MAX_PASSES, and fail the JIT if it does not converge.
--- arch/powerpc/net/bpf_jit.h | 7 +++++++ arch/powerpc/net/bpf_jit_comp.c | 34 +++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-)
arch/powerpc/net/bpf_jit.h +7 -0
@@ -14,6 +14,13 @@#include <asm/ppc-opcode.h> #include <linux/build_bug.h> +/* +* We need at least 2 passes for proper code generation, and may need +* additional passes if code size changes between passes. +*/ +#define CODEGEN_MIN_PASSES 2 +#define CODEGEN_MAX_PASSES 3 +#ifdef CONFIG_PPC64_ELF_ABI_V1 #define FUNCTION_DESCR_SIZE 24#else
arch/powerpc/net/bpf_jit_comp.c +26 -8
@@ -99,11 +99,10 @@ void bpf_jit_build_fentry_stubs(u32 *image, struct codegen_context *ctx)int bpf_jit_emit_exit_insn (u32 *image,struct codegen_context *ctx,int tmp_reg,long exit_addr) { -if (!exit_addr ||is_offset_in_branch_range (exit_addr - (ctx->idx *4 ))) { +if (exit_addr &&is_offset_in_branch_range (exit_addr - (long )(ctx->idx *4 ))) {PPC_JMP (exit_addr); - }else if (ctx->alt_exit_addr) { -if (WARN_ON (!is_offset_in_branch_range ((long )ctx->alt_exit_addr - (ctx->idx *4 )))) -return -1 ; + }else if (ctx->alt_exit_addr &&is_offset_in_branch_range ( + (long )(ctx->alt_exit_addr) - (long )(ctx->idx *4 ))) {PPC_JMP (ctx->alt_exit_addr); }else { ctx->alt_exit_addr = ctx->idx *4 ;
@@ -274,6 +273,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr*/ if (cgctx.seen &SEEN_TAILCALL || !is_offset_in_branch_range ((long )cgctx.idx *4 )) { cgctx.idx =0 ; + cgctx.alt_exit_addr =0 ;if (bpf_jit_build_body (fp,NULL ,NULL , &cgctx, addrs,0 , false)) goto out_err; }
@@ -306,10 +306,13 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr code_base = (u32 *)(image +FUNCTION_DESCR_SIZE ); fcode_base = (u32 *)(fimage +FUNCTION_DESCR_SIZE ); -/* Code generation passes 1-2 */ -for (pass =1 ; pass <3 ; pass++) { +/* Code generation passes 1-2+, loop until program size converges. */ +for (pass =1 ; pass <=CODEGEN_MAX_PASSES ; pass++) { +u32 prev_proglen = proglen; +/* Now build the prologue, body code & epilogue for real. */ cgctx.idx =0 ; + cgctx.exentry_idx =0 ; cgctx.alt_exit_addr =0 ;bpf_jit_build_prologue (code_base, &cgctx); if (bpf_jit_build_body(fp, code_base, fcode_base, &cgctx, addrs, pass,
@@ -318,11 +321,26 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prbpf_jit_binary_pack_free (fhdr, hdr); goto out_err; } + addrs[fp->len] = cgctx.idx *4 ;bpf_jit_build_epilogue (code_base, &cgctx); + proglen = cgctx.idx *4 ; +if (bpf_jit_enable >1 )pr_info ("Pass %d: shrink = %d, seen = 0x%x\n" , pass, - proglen - (cgctx.idx *4 ), cgctx.seen); + prev_proglen - proglen, cgctx.seen); + +/* Check if program size has converged, but ensure minimum passes */ +if (pass >=CODEGEN_MIN_PASSES && proglen == prev_proglen) +break ; + +if (pass ==CODEGEN_MAX_PASSES && proglen != prev_proglen) { +pr_err ("BPF JIT: Program did not converge after %d passes\n" , +CODEGEN_MAX_PASSES ); +bpf_arch_text_copy (&fhdr->size, &hdr->size,sizeof (hdr->size)); +bpf_jit_binary_pack_free (fhdr, hdr); + goto out_err; + } }if (bpf_jit_enable >1 )
@@ -399,7 +417,7 @@ int bpf_add_extable_entry(struct bpf_prog *fp, u32 *image, u32 *fimage, int passu32 *fixup;/* Populate extable entries only in the last pass */ -if (pass !=2 ) +if (pass <CODEGEN_MIN_PASSES )return 0 ; if (!fp->aux->extable ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 375/1257 powerpc/bpf: fix alignment of long branch trampoline address
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Dubey <[email protected]>
[ Upstream commit 04001e8ddb979f463f1c3ca8ac4d6ac59fb48921 ]
Ensure the dummy trampoline address field present between the OOL stub and the long branch stub is 4/8-byte aligned, for memory compatibility when content loaded to a register.
--- arch/powerpc/net/bpf_jit.h | 7 +++--- arch/powerpc/net/bpf_jit_comp.c | 38 ++++++++++++++++++++++++++----- arch/powerpc/net/bpf_jit_comp32.c | 7 +++--- arch/powerpc/net/bpf_jit_comp64.c | 7 +++--- 4 files changed, 44 insertions(+), 15 deletions(-)
arch/powerpc/net/bpf_jit.h +4 -3
@@ -221,10 +221,11 @@ int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *int bpf_jit_build_body (struct bpf_prog *fp,u32 *image,u32 *fimage,struct codegen_context *ctx,u32 *addrs,int pass,bool extra_pass);void bpf_jit_build_prologue (u32 *image,struct codegen_context *ctx); -void bpf_jit_build_epilogue (u32 *image,struct codegen_context *ctx); -void bpf_jit_build_fentry_stubs (u32 *image,struct codegen_context *ctx); +void bpf_jit_build_epilogue (u32 *image,u32 *fimage,struct codegen_context *ctx); +void bpf_jit_build_fentry_stubs (u32 *image,u32 *fimage,struct codegen_context *ctx);void bpf_jit_realloc_regs (struct codegen_context *ctx); -int bpf_jit_emit_exit_insn (u32 *image,struct codegen_context *ctx,int tmp_reg,long exit_addr); +int bpf_jit_emit_exit_insn (u32 *image,u32 *fimage,struct codegen_context *ctx,int tmp_reg, +long exit_addr);void prepare_for_fsession_fentry (u32 *image,struct codegen_context *ctx,int cookie_cnt,int cookie_off,int retval_off);void store_func_meta (u32 *image,struct codegen_context *ctx,u64 func_meta,int func_meta_off);
arch/powerpc/net/bpf_jit_comp.c +32 -6
@@ -49,11 +49,35 @@ asm (" .popsection ;" ); -void bpf_jit_build_fentry_stubs (u32 *image,struct codegen_context *ctx) +void bpf_jit_build_fentry_stubs (u32 *image,u32 *fimage,struct codegen_context *ctx) {int ool_stub_idx, long_branch_stub_idx; +int ool_stub_sz;/* +* Align the mis-aligned dummy_tramp_addr field in the fimage. +* The alignment NOP must appear before OOL stub, to make +* ool_stub_idx & long_branch_stub_idx constant from end. +* +* The fimage can be non 8-byte aligned, so final alignment depends +* on start of fimage and the stub's instruction count offset. The +* OOL stub size is 4 instructions (with CONFIG_PPC_FTRACE_OUT_OF_LINE) +* or 3 instructions (without) before dummy_tramp_addr. +* +* Emit a NOP here if address is not SZL aligned. +* +* In pass=0 when image==NULL, conservatively account for space +* required to accommodate alignment NOP. In case final pass skips +* emitting alignment NOP, the image buffer have 4 spare bytes and +* jited_len signifies correct program size. +*/ + + ool_stub_sz =IS_ENABLED (CONFIG_PPC_FTRACE_OUT_OF_LINE ) ?16 :12 ; +if (!image || !IS_ALIGNED ((unsigned long )fimage + ctx->idx*4 + ool_stub_sz,SZL )) +EMIT (PPC_RAW_NOP ()); + +/* +* nop // optional, for alignment of dummy_tramp_addr * Out-of-line stub: * mflr r0 * [b|bl] tramp
@@ -70,7 +94,7 @@ void bpf_jit_build_fentry_stubs(u32 *image, struct codegen_context *ctx)/* * Long branch stub: -* .long <dummy_tramp_addr> +* .long <dummy_tramp_addr> // 8-byte aligned * mflr r11 * bcl 20,31,$+4 * mflr r12
@@ -81,6 +105,7 @@ void bpf_jit_build_fentry_stubs(u32 *image, struct codegen_context *ctx)*/ if (image) *((unsigned long *)&image[ctx->idx]) = (unsigned long )dummy_tramp; + ctx->idx +=SZL /4 ; long_branch_stub_idx = ctx->idx;EMIT (PPC_RAW_MFLR (_R11));
@@ -97,7 +122,8 @@ void bpf_jit_build_fentry_stubs(u32 *image, struct codegen_context *ctx) } } -int bpf_jit_emit_exit_insn (u32 *image,struct codegen_context *ctx,int tmp_reg,long exit_addr) +int bpf_jit_emit_exit_insn (u32 *image,u32 *fimage,struct codegen_context *ctx, +int tmp_reg,long exit_addr) {if (exit_addr &&is_offset_in_branch_range (exit_addr - (long )(ctx->idx *4 ))) {PPC_JMP (exit_addr);
@@ -106,7 +132,7 @@ int bpf_jit_emit_exit_insn(u32 *image, struct codegen_context *ctx, int tmp_reg,PPC_JMP (ctx->alt_exit_addr); }else { ctx->alt_exit_addr = ctx->idx *4 ; -bpf_jit_build_epilogue (image, ctx); +bpf_jit_build_epilogue (image, fimage, ctx); }return 0 ;
@@ -286,7 +312,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr*/ bpf_jit_build_prologue (NULL , &cgctx); addrs[fp->len] = cgctx.idx *4 ; -bpf_jit_build_epilogue (NULL , &cgctx); +bpf_jit_build_epilogue (NULL ,NULL , &cgctx); fixup_len = fp->aux->num_exentries *BPF_FIXUP_LEN *4 ; extable_len = fp->aux->num_exentries *sizeof (struct exception_table_entry );
@@ -322,7 +348,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr goto out_err; } addrs[fp->len] = cgctx.idx *4 ; -bpf_jit_build_epilogue (code_base, &cgctx); +bpf_jit_build_epilogue (code_base, fcode_base, &cgctx); proglen = cgctx.idx *4 ;
arch/powerpc/net/bpf_jit_comp32.c +4 -3
@@ -229,7 +229,7 @@ static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx } -void bpf_jit_build_epilogue (u32 *image,struct codegen_context *ctx) +void bpf_jit_build_epilogue (u32 *image,u32 *fimage,struct codegen_context *ctx) {EMIT (PPC_RAW_MR (_R3,bpf_to_ppc (BPF_REG_0 )));
@@ -237,7 +237,7 @@ void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)EMIT (PPC_RAW_BLR ()); -bpf_jit_build_fentry_stubs (image, ctx); +bpf_jit_build_fentry_stubs (image, fimage, ctx); }/* Relative offset needs to be calculated based on final image location */
@@ -1149,7 +1149,8 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code* we'll just fall through to the epilogue. */ if (i != flen -1 ) { - ret =bpf_jit_emit_exit_insn (image, ctx, _R0, exit_addr); + ret =bpf_jit_emit_exit_insn (image, fimage, + ctx, _R0, exit_addr);if (ret)return ret; }
arch/powerpc/net/bpf_jit_comp64.c +4 -3
@@ -398,7 +398,7 @@ static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx } } -void bpf_jit_build_epilogue (u32 *image,struct codegen_context *ctx) +void bpf_jit_build_epilogue (u32 *image,u32 *fimage,struct codegen_context *ctx) {bpf_jit_emit_common_epilogue (image, ctx);
@@ -407,7 +407,7 @@ void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)EMIT (PPC_RAW_BLR ()); -bpf_jit_build_fentry_stubs (image, ctx); +bpf_jit_build_fentry_stubs (image, fimage, ctx); }/*
@@ -1737,7 +1737,8 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code* we'll just fall through to the epilogue. */ if (i != flen -1 ) { - ret =bpf_jit_emit_exit_insn (image, ctx, tmp1_reg, exit_addr); + ret =bpf_jit_emit_exit_insn (image, fimage, ctx, + tmp1_reg, exit_addr);if (ret)return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 376/1257 pseries/plpks: fix error handling in plpks_read_var()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit d52a1659cb1718f93166ab8dd8621237e564a1c4 ]
When a PLPKS variable is initialized without a policy and used to read an object with the PLPKS_WRAPPINGKEY policy set, the hypervisor returns H_AUTHORITY along with the object's policy. However, plpks_read_var() currently treats this the same as any other H_AUTHORITY failure and returns an error without propagating the policy information to the caller.
Distinguish this case from other H_AUTHORITY failures and propagate the returned policy to the caller while preserving the authorization error. Remove the explicit assignment of zero to rc on H_SUCCESS, as it is redundant.
Also validate the PLPKS variable pointer before dereferencing it.
--- arch/powerpc/platforms/pseries/plpks.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/powerpc/platforms/pseries/plpks.c +8 -6
@@ -822,6 +822,9 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)u8 *output;int rc; +if (!var) +return -EINVAL ; +if (var->namelen >PLPKS_MAX_NAME_SIZE )return -EINVAL ;
@@ -856,22 +859,21 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)virt_to_phys (var->name), var->namelen,virt_to_phys (output), maxobjsize); -if (rc !=H_SUCCESS ) { rc =pseries_status_to_err (rc); - goto out_free_output; +if (rc != -EPERM || !retbuf[1 ]) + goto out_free_output; + goto out_copy_policy; }if (!var->data || var->datalen > retbuf[0 ]) var->datalen = retbuf[0 ]; - var->policy = retbuf[1 ]; -if (var->data)memcpy (var->data, output, var->datalen); - rc =0 ; - +out_copy_policy: + var->policy = retbuf[1 ]; out_free_output:kfree (output); out_free_label:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 377/1257 pseries/plpks: fix error code for wrapping key reads
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit 0d0eafedcaf4939819d38ede6ad355ea37acd978 ]
PLPKS variables with the PLPKS_WRAPPINGKEY policy bit set are not readable. Return -EPERM instead of -EINVAL in this case to better reflect the access restriction being enforced.
--- arch/powerpc/platforms/pseries/plpks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/plpks.c +1 -1
@@ -829,7 +829,7 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)return -EINVAL ;if (var->policy &PLPKS_WRAPPINGKEY ) -return -EINVAL ; +return -EPERM ; auth =construct_auth (consumer);if (IS_ERR (auth))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 378/1257 pseries/plpks: validate input to plpks_signed_update_var()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit b59ff2d50b817eeec1259f357aae821c7834007f ]
plpks_signed_update_var() dereferences the supplied PLPKS variable pointer without validating it. A NULL argument could therefore result in a NULL pointer dereference.
Reject a NULL pointer argument with -EINVAL.
--- arch/powerpc/platforms/pseries/plpks.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/platforms/pseries/plpks.c +3 -0
@@ -637,6 +637,9 @@ int plpks_signed_update_var(struct plpks_var *var, u64 flags)u64 continuetoken =0 ;u64 timeout =0 ; +if (!var) +return -EINVAL ; +if (!var->data || var->datalen <=0 || var->namelen >PLPKS_MAX_NAME_SIZE )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 379/1257 pseries/plpks: clear sensitive PLPKS buffers
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit fe18716ff314eb32299048fd64242d31b4e852cf ]
PLPKS read, remove, and write operations use authentication buffers that contain passwords. The read output buffer may also contain sensitive data. Freeing these buffers with kfree(), without wiping the contents, can leave sensitive data in memory.
Use kfree_sensitive() to wipe the buffers when freeing them.
--- arch/powerpc/platforms/pseries/plpks.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/pseries/plpks.c +4 -4
@@ -754,7 +754,7 @@ int plpks_write_var(struct plpks_var var) rc =pseries_status_to_err (rc);kfree (label); out: -kfree (auth); +kfree_sensitive (auth);return rc; }
@@ -812,7 +812,7 @@ int plpks_remove_var(char *component, u8 varos, struct plpks_var_name vname) rc =pseries_status_to_err (rc);kfree (label); out: -kfree (auth); +kfree_sensitive (auth);return rc; }
@@ -878,11 +878,11 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var) out_copy_policy: var->policy = retbuf[1 ]; out_free_output: -kfree (output); +kfree_sensitive (output); out_free_label:kfree (label); out_free_auth: -kfree (auth); +kfree_sensitive (auth);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 380/1257 pseries/plpks: clear sensitive buffers in wrapping operations
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit 203695c109e37d8fe3531844218f75b98eef8e1f ]
PLPKS wrapping key generation, object wrapping, and object unwrapping use authentication buffers that contain passwords. An object unwrapping failure also frees an output buffer that may contain sensitive data. Freeing these buffers with kfree(), without wiping the contents, can leave sensitive data in memory.
Use kfree_sensitive() to wipe the buffers when freeing them.
--- arch/powerpc/platforms/pseries/plpks.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/pseries/plpks.c +4 -4
@@ -975,7 +975,7 @@ int plpks_gen_wrapping_key(void)kfree (label); out: -kfree (auth); +kfree_sensitive (auth);return rc; }EXPORT_SYMBOL_GPL (plpks_gen_wrapping_key);
@@ -1100,7 +1100,7 @@ int plpks_wrap_object(u8 **input_buf, u32 input_len, u16 wrap_flags, out_free_label:kfree (label); out: -kfree (auth); +kfree_sensitive (auth);return rc; }EXPORT_SYMBOL_GPL (plpks_wrap_object);
@@ -1177,14 +1177,14 @@ int plpks_unwrap_object(u8 **input_buf, u32 input_len, u8 **output_buf,if (rc) {pr_err ("H_PKS_UNWRAP_OBJECT failed. pseries_status=%d, rc=%d" , pseries_status, rc); -kfree (*output_buf); +kfree_sensitive (*output_buf); *output_buf =NULL ; }else { *output_len = retbuf[1 ]; } out: -kfree (auth); +kfree_sensitive (auth);return rc; }EXPORT_SYMBOL_GPL (plpks_unwrap_object);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 381/1257 pseries/plpks: clear signed update authentication buffer
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit 63de55024e7c85975f4410380323edb05b186d7c ]
The PLPKS signed update operation uses an authentication buffer that contains a password. Freeing this buffer with kfree(), without wiping the contents, can leave sensitive data in memory.
Use kfree_sensitive() to wipe the buffer when freeing it.
--- arch/powerpc/platforms/pseries/plpks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/plpks.c +1 -1
@@ -685,7 +685,7 @@ int plpks_signed_update_var(struct plpks_var *var, u64 flags)kfree (label); out: -kfree (auth); +kfree_sensitive (auth);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 382/1257 pseries/plpks: clear SED key data after use
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit 217ba01e5b9096091acc2c1a3776cb3eb88c00ff ]
Explicitly clear the temporary buffer containing SED key data after read and write operations.
--- arch/powerpc/platforms/pseries/plpks_sed_ops.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/powerpc/platforms/pseries/plpks_sed_ops.c +9 -3
@@ -84,14 +84,16 @@ int sed_read_key(char *keyname, char *key, u_int *keylen) ret =plpks_read_os_var (&var);if (ret !=0 ) -return ret; + goto out; len =min_t (u16,be32_to_cpu (data.key_len), var.datalen);memcpy (key, data.key, len); key[len] ='\0' ; *keylen = len; -return 0 ; +out: +memzero_explicit (&data,sizeof (data)); +return ret; }/*
@@ -102,6 +104,7 @@ int sed_write_key(char *keyname, char *key, u_int keylen)struct plpks_var var;struct plpks_sed_object_data data;struct plpks_var_name vname; +int ret;plpks_init_var (&var, keyname);
@@ -127,5 +130,8 @@ int sed_write_key(char *keyname, char *key, u_int keylen) vname.name = var.name;plpks_remove_var (var.component, var.os, vname); -return plpks_write_var (var); + ret =plpks_write_var (var); +memzero_explicit (&data,sizeof (data)); + +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 383/1257 pseries/plpks: fix self-reference in plpks_var initializer
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit abcccecf4aa4b681f50eb7d7de93fc9a0a61c181 ]
In plpks_gen_wrapping_key() and plpks_wrap_object(), strlen(var.name) is used to initialize var.namelen within the same struct initializer. This references a member of var before initialization of var is complete.
Use the compile-time length of PLPKS_WRAPKEY_NAME instead.
--- arch/powerpc/platforms/pseries/plpks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/plpks.c +2 -2
@@ -939,7 +939,7 @@ int plpks_gen_wrapping_key(void)int rc =0 , pseries_status =0 ;struct plpks_var var = { .name =PLPKS_WRAPKEY_NAME , - .namelen =strlen (var.name), + .namelen =sizeof (PLPKS_WRAPKEY_NAME ) -1 , .policy =PLPKS_WRAPPINGKEY , .os =PLPKS_VAR_LINUX , .component =PLPKS_WRAPKEY_COMPONENT
@@ -1034,7 +1034,7 @@ int plpks_wrap_object(u8 **input_buf, u32 input_len, u16 wrap_flags,bool sb_enforce_bit = wrap_flags &BIT (1 );struct plpks_var var = { .name =PLPKS_WRAPKEY_NAME , - .namelen =strlen (var.name), + .namelen =sizeof (PLPKS_WRAPKEY_NAME ) -1 , .os =PLPKS_VAR_LINUX , .component =PLPKS_WRAPKEY_COMPONENT };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 384/1257 pseries/plpks: hide wrapping_features when unsupported
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srish Srinivasan <[email protected]>
[ Upstream commit 46b8411b2ee948b1786bc4af76e7feede0c2ddff ]
The PLPKS wrapping features config is only valid on systems that support the "Key Wrapping" feature. Currently the config is always exposed, even when the feature is unavailable.
Add an is_visible() callback to suppress the wrapping_features sysfs attribute when the "Key Wrapping" feature is not supported. Declare the attribute group static const, as it is not modified after initialization.
--- arch/powerpc/platforms/pseries/plpks-sysfs.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
arch/powerpc/platforms/pseries/plpks-sysfs.c +15 -5
@@ -45,6 +45,16 @@ static const struct attribute *config_attrs[] = {static struct kobject *plpks_kobj, *plpks_config_kobj; +static umode_t plpks_config_attr_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +if (attr == &attr_wrapping_features.attr && + !plpks_wrapping_is_supported ()) +return 0 ; + +return attr->mode; +} +int plpks_config_create_softlink (struct kobject *from) {if (!plpks_config_kobj)
@@ -52,13 +62,13 @@ int plpks_config_create_softlink(struct kobject *from)return sysfs_create_link (from, plpks_config_kobj,"config" ); } +static const struct attribute_group config_group = { + .attrs = (struct attribute **)config_attrs, + .is_visible = plpks_config_attr_is_visible, +}; +static __init int plpks_sysfs_config (struct kobject *kobj) { -struct attribute_group config_group = { - .name =NULL , - .attrs = (struct attribute **)config_attrs, - }; -return sysfs_create_group (kobj, &config_group); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 385/1257 powerpc/pseries/iommu: Add TCEs for 16GB pages when RAM is pre-mapped
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gaurav Batra <[email protected]>
[ Upstream commit 0b8b0c17a8998709ecb2852d56442ea981102941 ]
In powerPC, if Dynamic DMA Window is big enough, RAM is pre-mapped. To determine the size of RAM, a PAPR+ property "ibm,lrdr-capacity" is used. This OF property dictates what is the max size of RAM an LPAR can have, including DR added memory.
In PowerPC, 16GB pages can be allocated at machine level and then assigned to LPARs. These 16GB pages are added to LPAR memory at the time of boot. The address range for these 16GB pages is above MAX RAM an LPAR can have (ibm,lrdr-capacity). In the current implementation, these 16GB pages are being excluded from pre-mapped TCEs. A driver can have DMA buffers allocated from 16GB pages. This results in platform to raise an EEH when DMA is attempted on buffers in 16GB memory range.
commit 6aa989ab2bd0 ("powerpc/pseries/iommu: memory notifier incorrectly adds TCEs for pmemory")
Prior to the above patch, memblock_end_of_DRAM() was being used to determine the MAX memory of an LPAR. This included 16GB pages as well. The issue with using memblock_end_of_DRAM() is that when pmemory is converted to RAM via daxctl command, the DDW engine will incorrectly try to add TCEs for pmemory as well.
Below is the address distribution of RAM, 16GB pages and pmemory for an LPAR with max memory of 256GB, memory allocated 64GB, 2 16GB pages and assigned pmemory of 8GB.
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x0000000fffffffff 64G online yes 0-255 0x0000004000000000-0x00000047ffffffff 32G online yes 1024-1151
cat /sys/bus/nd/devices/region0/resource0x40100000000
cat /sys/bus/nd/devices/region0/size
8589934592
The approach to fix this problem is to revert back the code changes introduced by the above patch and to stash away the MAX memory of an LPAR, including 16GB pages, at the LPAR boot time. This value is then used whenever TCEs are needed to be pre-mapped - enable_DDW() or, iommu_mem_notifier()
--- arch/powerpc/platforms/pseries/iommu.c | 67 +++++++++++++++++--------- 1 file changed, 45 insertions(+), 22 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +45 -22
@@ -69,6 +69,8 @@ static struct iommu_table *iommu_pseries_alloc_table(int node)return tbl; } +static phys_addr_t pseries_ddw_max_ram__ro_after_init ; +#ifdef CONFIG_IOMMU_API static struct iommu_table_group_ops spapr_tce_table_group_ops;#endif
@@ -1284,15 +1286,19 @@ struct failed_ddw_pdn {static LIST_HEAD (failed_ddw_pdn_list); -static phys_addr_t ddw_memory_hotplug_max (void ) +static phys_addr_t __init ddw_memory_hotplug_max (void ) { -resource_size_t max_addr; +resource_size_t max_addr =memory_hotplug_max (); +struct device_node *memory; -#if defined(CONFIG_NUMA ) && defined(CONFIG_MEMORY_HOTPLUG ) - max_addr =hot_add_drconf_memory_max (); -#else - max_addr =memblock_end_of_DRAM (); -#endif +for_each_node_by_type (memory,"memory" ) { +struct resource res; + +if (of_address_to_resource (memory,0 , &res)) +continue ; + + max_addr =max_t (resource_size_t, max_addr, res.end +1 ); + }return max_addr; }
@@ -1447,7 +1453,7 @@ static struct property *ddw_property_create(const char *propname, u32 liobn, u64static bool enable_ddw (struct pci_dev *dev,struct device_node *pdn,u64 dma_mask) {int len =0 , ret; -int max_ram_len =order_base_2 (ddw_memory_hotplug_max ()); +int max_ram_len =order_base_2 (pseries_ddw_max_ram);struct ddw_query_response query;struct ddw_create_response create;int page_shift;
@@ -1617,12 +1623,12 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn, u64 dma_masif (default_win_removed && pmem_present && !direct_mapping) {/* DDW is big enough to be split */ if ((1ULL << ddw_sz) >= -MIN_DDW_VPMEM_DMA_WINDOW + (1ULL << max_ram_len)) { +MIN_DDW_VPMEM_DMA_WINDOW + pseries_ddw_max_ram) { direct_mapping = true;/* offset of the Dynamic part of DDW */ - dynamic_offset =1ULL << max_ram_len; + dynamic_offset = pseries_ddw_max_ram; }/* DDW will at least have dynamic allocation */
@@ -1669,7 +1675,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn, u64 dma_masif (direct_mapping) {/* DDW maps the whole partition, so enable direct DMA mapping */ - ret =walk_system_ram_range (0 ,ddw_memory_hotplug_max () >>PAGE_SHIFT , + ret =walk_system_ram_range (0 , pseries_ddw_max_ram >>PAGE_SHIFT , win64->value, tce_setrange_multi_pSeriesLP_walk);if (ret) { dev_info(&dev->dev, "failed to map DMA window for %pOF: %d\n",
@@ -1772,8 +1778,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn, u64 dma_mas/* For pre-mapped memory, set bus_dma_limit to the max RAM */ if (direct_mapping) - dev->dev.bus_dma_limit = dev->dev.archdata.dma_offset + - (1ULL << max_ram_len); + dev->dev.bus_dma_limit = dev->dev.archdata.dma_offset + pseries_ddw_max_ram;dev_info (&dev->dev,"lsa_required: %x, lsa_enabled: %x, direct mapping: %x\n" , limited_addr_req, limited_addr_enabled, direct_mapping);
@@ -2420,23 +2425,35 @@ static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action, {struct dma_win *window;struct memory_notify *arg = data; +unsigned long limit = arg->nr_pages; +unsigned long max_ram_pages = pseries_ddw_max_ram >>PAGE_SHIFT ;int ret =0 ;/* This notifier can get called when onlining persistent memory as well. * TCEs are not pre-mapped for persistent memory. Persistent memory will -* always be above ddw_memory_hotplug_max() +* always be above pseries_ddw_max_ram */ +if (arg->start_pfn >= max_ram_pages) +return NOTIFY_OK ; + +/* RAM is being DLPAR'ed. The range should never exceed max ram. +* Just in case, clamp the range and throw a warning. +*/ +if (arg->start_pfn + limit > max_ram_pages) { + limit = max_ram_pages - arg->start_pfn; +WARN_ONCE (1 ,"Limiting Page Range %lx - %lx to Max Mem Pages: %lx\n" , + arg->start_pfn, arg->start_pfn + arg->nr_pages, + max_ram_pages); + }switch (action) {case MEM_GOING_ONLINE :spin_lock (&dma_win_list_lock);list_for_each_entry (window, &dma_win_list, list) { -if (window->direct && (arg->start_pfn <<PAGE_SHIFT ) < -ddw_memory_hotplug_max ()) { +if (window->direct) { ret |=tce_setrange_multi_pSeriesLP (arg->start_pfn, - arg->nr_pages, window->prop); + limit, window->prop); } -/* XXX log error */ }spin_unlock (&dma_win_list_lock);break ;
@@ -2444,12 +2461,10 @@ static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,case MEM_OFFLINE :spin_lock (&dma_win_list_lock);list_for_each_entry (window, &dma_win_list, list) { -if (window->direct && (arg->start_pfn <<PAGE_SHIFT ) < -ddw_memory_hotplug_max ()) { +if (window->direct) { ret |=tce_clearrange_multi_pSeriesLP (arg->start_pfn, - arg->nr_pages, window->prop); + limit, window->prop); } -/* XXX log error */ }spin_unlock (&dma_win_list_lock);break ;
@@ -2533,6 +2548,14 @@ void __init iommu_init_early_pSeries(void)register_memory_notifier (&iommu_mem_nb);set_pci_dma_ops (&dma_iommu_ops); + +/* During init determine the max memory an LPAR can have and set it. This +* will be used for pre-mapping RAM in DDW. memblock_end_of_DRAM() can +* change during the running of LPAR - daxctl can add pmemory as +* "system-ram". This memory range should not be pre-mapped in DDW since +* the address of pmemory can be much higher than the DDW size. +*/ + pseries_ddw_max_ram =ddw_memory_hotplug_max (); }static int __init disable_multitce (char *str)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 386/1257 ASoC: pcm6240: do not free an unrequested IRQ
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 995b96380ba5d98131acc162608da3538e1395d8 ]
The driver obtains an IRQ number from device tree but never requests an IRQ handler for the PCM6240 device. Removing the device must not pass that number to free_irq().
Leave IRQ ownership to a matching request path if one is added later.
--- sound/soc/codecs/pcm6240.c | 2 -- 1 file changed, 2 deletions(-)
sound/soc/codecs/pcm6240.c +0 -2
@@ -2019,8 +2019,6 @@ static const struct regmap_config pcmdevice_i2c_regmap = {static void pcmdevice_remove (struct pcmdevice_priv *pcm_dev) { -if (pcm_dev->irq) -free_irq (pcm_dev->irq, pcm_dev);mutex_destroy (&pcm_dev->codec_lock); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 387/1257 nilfs2: clear dirty flag on bdev buffers on log write failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 6faad04a002603d800134398fcd042b403b32d35 ]
Since the commit referenced in the Fixes tag stopped directly calling inode_attach_wb(), a dirty flag is set on buffers (with mark_buffer_dirty()) allocated to the backing device for segment summaries and the super root block during log writes.
While this dirty flag is cleared upon a successful log write, it remains uncleared if the log write fails.
Consequently, when a log write fails, these backing device buffers are left in an inconsistent state where their uptodate flag and the dirty flag of the containing page/folio are cleared, but the buffer's dirty flag remains as stale garbage.
Particularly when the block size is smaller than the page size, if other buffers on the same page/folio become dirty, this buffer unexpectedly becomes a target for writeback again. As a result, if the block is later reused for other data or metadata, that contents risks being corrupted.
Fix this issue by calling clear_buffer_dirty() for the backing device buffers when aborting log writes in nilfs_abort_logs().
--- fs/nilfs2/segment.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nilfs2/segment.c +2 -0
@@ -1829,6 +1829,7 @@ static void nilfs_abort_logs(struct list_head *logs, int err)list_for_each_entry (segbuf, logs, sb_list) {list_for_each_entry (bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) { +clear_buffer_dirty (bh);clear_buffer_uptodate (bh);if (bh->b_folio != bd_folio) {if (bd_folio)
@@ -1840,6 +1841,7 @@ static void nilfs_abort_logs(struct list_head *logs, int err)list_for_each_entry (bh, &segbuf->sb_payload_buffers, b_assoc_buffers) {if (bh == segbuf->sb_super_root) { +clear_buffer_dirty (bh);clear_buffer_uptodate (bh);if (bh->b_folio != bd_folio) {folio_end_writeback (bd_folio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 388/1257 clk: tenstorrent: Assign .num before accessing .hws
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
[ Upstream commit da9f1312b06e4c03d43d21494fb5beea7f9e096d ]
Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' with __counted_by, which informs the bounds sanitizer (UBSAN_BOUNDS) about the number of elements in .hws[], so that it can warn when .hws[] is accessed out of bounds. As noted in that change, the __counted_by member must be initialized with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialization because the number of elements is zero. This occurs in atlantis_prcm_clocks_register() due to .num being assigned only after every clock has been stored in .hws[]. With CONFIG_UBSAN_BOUNDS and a compiler that implements __counted_by (GCC 15.1+ or Clang 20.1+), this triggers an array-index-out-of-bounds report during probe, and with CONFIG_UBSAN_TRAP the first store traps so the clock provider never registers.
Move the .num initialization to right after the allocation.
--- drivers/clk/tenstorrent/atlantis-prcm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clk/tenstorrent/atlantis-prcm.c +2 -3
@@ -789,13 +789,14 @@ static int atlantis_prcm_clocks_register(struct device *dev, {struct clk_hw_onecell_data *clk_data;int i, ret; -size_t num_clks = data->num; clk_data =devm_kzalloc (dev,struct_size (clk_data, hws, data->num),GFP_KERNEL );if (!clk_data)return -ENOMEM ; + clk_data->num = data->num; +for (i =0 ; i < data->num; i++) {struct clk_hw *hw = data->hws[i]; struct atlantis_clk_common *common =
@@ -809,8 +810,6 @@ static int atlantis_prcm_clocks_register(struct device *dev, clk_data->hws[common->clkid] = hw; } - clk_data->num = num_clks; -return devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, clk_data); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 389/1257 clk: tenstorrent: Fix refcount leak on shared gate clk enable failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anirudh Srinivasan <[email protected]>
[ Upstream commit 3f0655b51eb01dad30d61ced0a81718211f2776e ]
atlantis_clk_gate_shared_enable() increments the refcount for the number of clks requesting the shared gate clk to be enabled always. It should only do this when the enable for the gate took effect in hardware. It's possible to end up in a situation where the gate enable failed, but the refcount is incremented anyway, so subsequent requests by other clks that share the same refcount get ignored and the gate enable is never retried.
Update this function so that the refcount is not incremented when the gate clk enable fails in hardware.
--- drivers/clk/tenstorrent/atlantis-prcm.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/clk/tenstorrent/atlantis-prcm.c +9 -10
@@ -397,22 +397,21 @@ static int atlantis_clk_gate_shared_enable(struct clk_hw *hw) scoped_guard(spinlock_irqsave, gate->config.refcount_lock) { - need_enable = (*gate->config.share_count)++ ==0 ; + need_enable = (*gate->config.share_count) ==0 ;if (need_enable) {regmap_set_bits (gate->common.regmap, gate->config.reg_offset, gate->config.enable); - } - } -if (need_enable) { -if (!regmap_test_bits (gate->common.regmap, - gate->config.reg_offset, - gate->config.enable)) { -pr_warn ("%s: gate enable %d failed to enable\n" , -clk_hw_get_name (hw), gate->config.enable); -return -EIO ; +if (!regmap_test_bits (gate->common.regmap, + gate->config.reg_offset, + gate->config.enable)) { +pr_warn ("%s: gate enable %d failed to enable\n" , +clk_hw_get_name (hw), gate->config.enable); +return -EIO ; + } } + (*gate->config.share_count)++; }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 390/1257 vfio/pci: Restore 8-byte ioeventfd support
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit b30b52c2fb82e6d38ee2845a4d85e8254b44f3d8 ]
Commit b44a06bd28f2 ("vfio/pci: Remove #ifdef iowrite64 and #ifdef ioread64") inadvertently converted a conditional 8-byte rejection into an unconditional one.
Originally, 'count == 8' was rejected only if iowrite64 was undefined (#ifndef iowrite64). When iowrite64 became globally available via generic fallbacks, this rejection became dead code, allowing 8-byte ioeventfds. However, b44a06bd28f2 removed the #ifndef wrappers but left the nested 'if (count == 8) return -EINVAL;' intact, breaking all 8-byte registrations.
Drop the unconditional check to restore 8-byte ioeventfd support, matching the original intent.
--- drivers/vfio/pci/vfio_pci_rdwr.c | 3 --- 1 file changed, 3 deletions(-)
drivers/vfio/pci/vfio_pci_rdwr.c +0 -3
@@ -423,9 +423,6 @@ int vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset, pos >= vdev->msix_offset + vdev->msix_size))return -EINVAL ; -if (count ==8 ) -return -EINVAL ; - io =vfio_pci_core_get_iomap (vdev, bar);if (IS_ERR (io))return PTR_ERR (io);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/1257 nilfs2: ignore non-fatal signals during synchronous log write wait
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 7131aaa74bcc7c9da1f1d1c8724da75c775557a0 ]
Based on a syzbot report, Wang Jianjian pointed out that following a successful directory operation in nilfs_rename(), a synchronous write requested within nilfs_transaction_commit(), triggered by a sync flag set by nilfs_commit_chunk(), could be interrupted by a user signal. This interruption leaves in-memory metadata updates intact while returning an error, causing inconsistency with the VFS dentry cache and ultimately triggering a kernel warning.
According to "signal(7)", local disks are not classified as "slow devices" (such as terminals, FIFOs, or pipes) and their I/O operations on disk devices are not interrupted by signals. In kernel space, waiting for such disk I/O should therefore not be aborted by ordinary (non-fatal) signals.
Suppress this issue by modifying nilfs_segctor_sync(), which waits for the log writer thread to complete synchronous writes, to catch only fatal signals via fatal_signal_pending() and return -EINTR rather than -ERESTARTSYS. To complement this change and prevent the wait loop from busy-looping when schedule() returns immediately due to a pending non-fatal signal, switch the wait state from TASK_INTERRUPTIBLE to TASK_KILLABLE.
This serves as an effective interim stabilization measure without structural changes until a comprehensive fix for metadata consistency is implemented.
--- fs/nilfs2/ioctl.c | 2 +- fs/nilfs2/recovery.c | 2 +- fs/nilfs2/segment.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/nilfs2/ioctl.c +1 -1
@@ -965,10 +965,10 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,* Return: 0 on success, or one of the following negative error codes on * failure: * * %-EFAULT - Failure during execution of requested operation. +* * %-EINTR - Interrupted. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
fs/nilfs2/recovery.c +1 -1
@@ -785,11 +785,11 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EINVAL - Inconsistent filesystem state. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. */ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
fs/nilfs2/segment.c +5 -5
@@ -2259,7 +2259,7 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci)wake_up (&sci->sc_wait_daemon);for (;;) { -set_current_state (TASK_INTERRUPTIBLE ); +set_current_state (TASK_KILLABLE );/* * Synchronize only while the log writer thread is alive.
@@ -2273,11 +2273,11 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci) err = wait_req.err;break ; } -if (!signal_pending (current)) { +if (!fatal_signal_pending (current)) {schedule ();continue ; } - err = -ERESTARTSYS ; + err = -EINTR ;break ; }finish_wait (&sci->sc_wait_request, &wait_req.wq);
@@ -2311,10 +2311,10 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err, bool force)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_segment (struct super_block *sb)
@@ -2341,10 +2341,10 @@ int nilfs_construct_segment(struct super_block *sb)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/1257 pwm: tiehrpwm: Clear period on disable to allow reconfiguration
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
[ Upstream commit e74b9a7ee50071aad25d3989bf985292f90b0c6e ]
Both channels share one period register, so ehrpwm_pwm_config() rejects a period differing from the sibling's period_cycles[]. That value was cleared only in .free(), not in .disable(), so a stopped channel kept blocking the sibling from switching to a new frequency. Clear it in .disable() too.
Testcase:
cd /sys/class/pwm/pwmchip0; echo 0 > export; echo 1 > export for p in pwm0 pwm1; do
echo 1000000 > $p/period; echo 500000 > $p/duty_cycle
echo 1 > $p/enable; echo 0 > $p/enable; echo 2000000 > $p/period done
echo 1 > pwm0/enable # before: -EINVAL, after: succeeds
--- drivers/pwm/pwm-tiehrpwm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pwm/pwm-tiehrpwm.c +3 -0
@@ -358,6 +358,9 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)/* Disable clock on PWM disable */ pm_runtime_put_sync (pwmchip_parent (chip)); + +/* A disabled channel must not constrain the sibling's period */ + pc->period_cycles[pwm->hwpwm] =0 ; }static void ehrpwm_pwm_free (struct pwm_chip *chip,struct pwm_device *pwm)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/1257 IB/hfi1: Shutdown self-rearming timers before freeing
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9d3259e41ccd5016cd2c6d013232b89df6d73011 ]
The HFI1 receive error and synthetic counter timers rearm themselves from their callbacks. Their cleanup paths use timer_delete_sync(), which only waits for a running callback and does not prevent a concurrent or subsequent rearm.
Use timer_shutdown_sync() when releasing these timers. This prevents a callback from enqueueing either timer after cleanup begins, before the containing hfi1_devdata is freed.
Preserve the existing work cancellation and workqueue destruction ordering for synthetic counters.
--- drivers/infiniband/hw/hfi1/chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +2 -2
@@ -5567,7 +5567,7 @@ static int init_rcverr(struct hfi1_devdata *dd)static void free_rcverr (struct hfi1_devdata *dd) {if (dd->rcverr_timer.function) -timer_delete_sync (&dd->rcverr_timer); +timer_shutdown_sync (&dd->rcverr_timer); }static void handle_rxe_err (struct hfi1_devdata *dd,u32 unused,u64 reg)
@@ -12300,7 +12300,7 @@ static void free_cntrs(struct hfi1_devdata *dd)int i;if (dd->synth_stats_timer.function) -timer_delete_sync (&dd->synth_stats_timer); +timer_shutdown_sync (&dd->synth_stats_timer);cancel_work_sync (&dd->update_cntr_work); ppd = (struct hfi1_pportdata *)(dd +1 );for (i =0 ; i < dd->num_pports; i++, ppd++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/1257 arm64: dts: freescale: imx95-aquila: Enable I2C_3_DSI1 on Clover board
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Franz Schnyder <[email protected]>
[ Upstream commit cffbc25c212bd41885094648918a935da0115a0e ]
Enable lpi2c8, which is used for the I2C_3_DSI1 signals on the Clover carrier board. It was left disabled by mistake in the initial commit.
--- arch/arm64/boot/dts/freescale/imx95-aquila-clover.dts | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/freescale/imx95-aquila-clover.dts +5 -0
@@ -188,6 +188,11 @@ &lpi2c5 { status = "okay"; }; +/* Aquila I2C_3_DSI1 */ +&lpi2c8 { + status = "okay"; +}; + /* Aquila SPI_1 */ &lpspi6 { pinctrl-names = "default";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/1257 i3c: master: adi: free the IRQ before unregistering the master
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 1c1e2d90aa452764df66bb1dd774aa0d06d89cc8 ]
adi_i3c_master_irq() is requested with devm_request_irq(), so it stays registered when adi_i3c_master_remove() runs, and the writes masking the controller IRQ sources do not synchronize with a handler that is already running on another CPU. i3c_master_unregister() then frees the struct i3c_dev_desc objects that master->ibi.slots[] still point to, so the IBI path in adi_i3c_master_handle_ibi() can dereference freed memory.
Fix this by storing the IRQ number in the private structure and calling devm_free_irq() after the IRQ sources are masked, so a running handler is finished before the master is torn down.
This issue was found by an in-house static analysis tool.
--- drivers/i3c/master/adi-i3c-master.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/i3c/master/adi-i3c-master.c +4 -0
@@ -115,6 +115,7 @@ struct adi_i3c_master {spinlock_t lock;/* Protect transfer */ } xferqueue;void __iomem *regs; +int irq;struct clk *clk;unsigned long i3c_scl_lim;struct {
@@ -957,6 +958,7 @@ static int adi_i3c_master_probe(struct platform_device *pdev) irq =platform_get_irq (pdev,0 );if (irq <0 )return irq; + master->irq = irq; version =readl (master->regs +ADI_AXI_REG_VERSION );if (ADI_AXI_PCORE_VER_MAJOR (version) !=1 )
@@ -1001,6 +1003,8 @@ static void adi_i3c_master_remove(struct platform_device *pdev)writel (0x00 , master->regs +REG_IRQ_MASK );writel (0x01 , master->regs +REG_ENABLE ); +devm_free_irq (&pdev->dev, master->irq, master); +i3c_master_unregister (&master->base); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/1257 drm/msm/hdmi_phy: Cleanup after msm_hdmi_phy_resource_enable() failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit d27f831aaf20aaf06e41ceb1b260e10672269155 ]
If msm_hdmi_phy_resource_enable() fails, e.g. when enabling regulators, it should reverse the state of things already changed. msm_hdmi_phy_resource_enable() is used also in probe path, thus such failure, which could be simple deferred probe, would leave these resources permanently enabled for the rest of the runtime.
Patchwork: https://patchwork.freedesktop.org/patch/752654/
--- drivers/gpu/drm/msm/hdmi/hdmi_phy.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi_phy.c +14 -2
@@ -67,16 +67,28 @@ int msm_hdmi_phy_resource_enable(struct hdmi_phy *phy) ret =regulator_bulk_enable (cfg->num_regs, phy->regs);if (ret) {DRM_DEV_ERROR (dev,"failed to enable regulators: (%d)\n" , ret); -return ret; + goto err_pm_put; }for (i =0 ; i < cfg->num_clks; i++) { ret =clk_prepare_enable (phy->clks[i]); -if (ret) +if (ret) {DRM_DEV_ERROR (dev,"failed to enable clock: %s (%d)\n" , cfg->clk_names[i], ret); + goto err_clk_unprepare; + } } +return 0 ; + +err_clk_unprepare: +for (; i >0 ; i--) +clk_disable_unprepare (phy->clks[i -1 ]); +regulator_bulk_disable (cfg->num_regs, phy->regs); + +err_pm_put: +pm_runtime_put_sync (dev); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/1257 drm/msm/hdmi: Handle msm_hdmi_power_on() errors during .atomic_pre_enable()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit dd6ecace57851878e62367a6f1a26dd5b9aa217f ]
Properly handle power up failures during .atomic_pre_enable() by aborting the .atomic_pre_enable() to avoid accessing registers why blocks did not bring up. Otherwise this could lead to imprecise aborts when accessing MMIO while entire power domain is off.
Patchwork: https://patchwork.freedesktop.org/patch/752652/
--- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 30 ++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +21 -9
@@ -13,14 +13,16 @@#include "msm_kms.h" #include "hdmi.h" -static void msm_hdmi_power_on (struct drm_bridge *bridge) +static int msm_hdmi_power_on (struct drm_bridge *bridge) {struct drm_device *dev = bridge->dev;struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi;int ret; -pm_runtime_resume_and_get (&hdmi->pdev->dev); + ret =pm_runtime_resume_and_get (&hdmi->pdev->dev); +if (ret) +return ret;if (hdmi->extp_clk) {DBG ("pixclock: %lu" , hdmi->pixclock);
@@ -29,9 +31,14 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)DRM_DEV_ERROR (dev->dev,"failed to set extp clk rate: %d\n" , ret); ret =clk_prepare_enable (hdmi->extp_clk); -if (ret) +if (ret) {DRM_DEV_ERROR (dev->dev,"failed to enable extp clk: %d\n" , ret); +pm_runtime_put (&hdmi->pdev->dev); +return ret; + } } + +return 0 ; }static void power_off (struct drm_bridge *bridge)
@@ -287,13 +294,18 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,msm_hdmi_set_timings (hdmi, &crtc_state->adjusted_mode); -mutex_lock (&hdmi->state_mutex); -if (!hdmi->power_on) { -msm_hdmi_phy_resource_enable (phy); -msm_hdmi_power_on (bridge); - hdmi->power_on = true; + scoped_guard(mutex, &hdmi->state_mutex) { +if (!hdmi->power_on) { +if (msm_hdmi_phy_resource_enable (phy)) +return ; + +if (msm_hdmi_power_on (bridge)) { +msm_hdmi_phy_resource_disable (phy); +return ; + } + hdmi->power_on = true; + } } -mutex_unlock (&hdmi->state_mutex);if (connector->display_info.is_hdmi)msm_hdmi_audio_update (hdmi);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/1257 drm/msm/hdmi_bridge: Correct poweroff/audio cleanup order in post_disable
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 0499f0576e4442d67c164119f9d7f75d3cc945e7 ]
Turning off the power in msm_hdmi_bridge_atomic_post_disable() should follow reverse order of powering up, not only because it is logical, but also because msm_hdmi_audio_update() accesses registers thus block should still be powered on.
Depending on specific timing, existing code could have accesses to MMIO of powered off block.
Patchwork: https://patchwork.freedesktop.org/patch/752655/
--- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +1 -1
@@ -339,10 +339,10 @@ static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge,msm_hdmi_phy_powerdown (phy);if (hdmi->power_on) { -power_off (bridge); hdmi->power_on = false;if (hdmi->connector->display_info.is_hdmi)msm_hdmi_audio_update (hdmi); +power_off (bridge);msm_hdmi_phy_resource_disable (phy); }mutex_unlock (&hdmi->state_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/1257 drm/msm/dsi: Fix VM leak in dsi_tx_buf_alloc_6g()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit ab91ba61871a896ca2ecc6e048d80a152136da44 ]
dsi_tx_buf_alloc_6g() takes a reference to the kms VM with drm_gpuvm_get() and stores it in msm_host->vm. If msm_gem_kernel_new() fails, the function returns early without dropping that reference. Since msm_host->tx_gem_obj is cleared on the error path, msm_dsi_tx_buf_free() will never see a non-NULL tx_gem_obj and thus never calls drm_gpuvm_put(), leaking the VM reference.
Drop the VM reference and clear msm_host->vm on the error path.
Patchwork: https://patchwork.freedesktop.org/patch/754332/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/dsi/dsi_host.c +2 -0
@@ -1254,6 +1254,8 @@ int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size)if (IS_ERR (data)) { msm_host->tx_gem_obj =NULL ; +drm_gpuvm_put (msm_host->vm); + msm_host->vm =NULL ;return PTR_ERR (data); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/1257 staging: greybus: uart: fix racy TIOCMIWAIT implementation
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit e94cda6551d4716b17353fc458baa9e85ddea9ff ]
Check the wakeup condition after adding the task to the waitqueue and updating the task state to avoid missing a racing modem status update or disconnect.
Store the old icount on entry and do not update it in the completion handler to avoid missing events or reporting spurious ones (due to modem status changes before TIOCMIWAIT was called).
--- drivers/staging/greybus/uart.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/staging/greybus/uart.c +18 -12
@@ -53,7 +53,6 @@ struct gb_tty {spinlock_t read_lock;spinlock_t write_lock;struct async_icount iocount; -struct async_icount oldcount;wait_queue_head_t wioctl;struct mutex mutex;u8 ctrlin;/* input control lines */
@@ -643,11 +642,16 @@ static int wait_serial_change(struct gb_tty *gb_tty, unsigned long arg)if (!(arg & (TIOCM_DSR |TIOCM_RI |TIOCM_CD )))return -EINVAL ; - do { +spin_lock_irq (&gb_tty->read_lock); + old = gb_tty->iocount; +spin_unlock_irq (&gb_tty->read_lock); + +add_wait_queue (&gb_tty->wioctl, &wait); +for (;;) { +set_current_state (TASK_INTERRUPTIBLE ); +spin_lock_irq (&gb_tty->read_lock); - old = gb_tty->oldcount; new = gb_tty->iocount; - gb_tty->oldcount = new;spin_unlock_irq (&gb_tty->read_lock);if ((arg &TIOCM_DSR ) && (old.dsr != new.dsr))
@@ -657,18 +661,20 @@ static int wait_serial_change(struct gb_tty *gb_tty, unsigned long arg)if ((arg &TIOCM_RI ) && (old.rng != new.rng))break ; -add_wait_queue (&gb_tty->wioctl, &wait); -set_current_state (TASK_INTERRUPTIBLE ); -schedule (); -remove_wait_queue (&gb_tty->wioctl, &wait);if (gb_tty->disconnected) { -if (arg &TIOCM_CD ) -break ; retval = -ENODEV ; - }else if (signal_pending (current)) { +break ; + } + +schedule (); + +if (signal_pending (current)) { retval = -ERESTARTSYS ; +break ; } - }while (!retval); + } +__set_current_state (TASK_RUNNING ); +remove_wait_queue (&gb_tty->wioctl, &wait);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/1257 staging: rtl8723bs: fix RX buffer OOB write from device-reported length
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
[ Upstream commit c52929073fccbc149267a2fd7458626a7e9abcfc ]
sd_recv_rxfifo() trusts the device-reported RX0_REQ_LEN value (hal->SdioRxFIFOSize, a u16 read from the card via CMD52) as the size of the next RX packet and passes it to sdio_read_port(), which copies that many bytes into the recvbuf skb whose data area is only MAX_RECVBUF_SZ (10240) bytes. A bogus device on SDIO can report up to 65535 bytes, causing a heap overflow of up to ~55KB past the skb buffer.
Bail out when the RX0_REQ_LEN exceeds MAX_RECVBUF_SZ. This is expected to keep behavior unchanged on normal devices.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- drivers/staging/rtl8723bs/hal/sdio_ops.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/staging/rtl8723bs/hal/sdio_ops.c +7 -0
@@ -644,6 +644,13 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)struct recv_priv *recv_priv;struct recv_buf *recvbuf; +/* RX0_REQ_LEN is device-reported; the skb buffer is only +* MAX_RECVBUF_SZ bytes, reject bogus lengths instead of +* overflowing past it. +*/ +if (size >MAX_RECVBUF_SZ ) +return NULL ; +/* Patch for some SDIO Host 4 bytes issue */ /* ex. RK3188 */ readsize =round_up (size,4 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/1257 media: mali-c55: add padding to mali_c55_params_ccm structure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 2d3873cadda8537d8991abb24484bc590001fcbe ]
The newly added structure has extra padding on the on some architectures, which triggers a pedantic uapi check:
./usr/include/linux/media/arm/mali-c55-config.h:807:1: error: padding struct size to alignment boundary with 2 bytes [-Werror=padded]
Add explicit padding here to avoid risking information leaks and incompatibilities between architectures.
--- include/uapi/linux/media/arm/mali-c55-config.h | 2 ++ 1 file changed, 2 insertions(+)
include/uapi/linux/media/arm/mali-c55-config.h +2 -0
@@ -794,12 +794,14 @@ struct mali_c55_params_mesh_shading_selection {* Q4.8 format * @gains: Gains for red, green and blue channels in unsigned Q4.8 format * @offs: Offsets for red, green and blue channels +* @__pad: Reserved bytes */ struct mali_c55_params_ccm {struct v4l2_isp_params_block_header header;__u16 coeffs[3 ][3 ];__u16 gains[3 ];__u16 offs[3 ]; +__u16 __pad; };/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/1257 media: renesas: rzv2h-ivc: manage runtime PM with devres
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 64e07ebcb3d054672cff678edb5344586d2d3286 ]
Runtime PM is enabled before the IRQ is looked up. If that lookup fails, probe returns without disabling runtime PM. The subdevice initialization error path disables runtime PM but leaves autosuspend enabled, while the remove path does neither.
Use devm_pm_runtime_enable() so the driver core disables autosuspend and runtime PM on every failed probe and after remove. This also makes the manual subdevice error unwind unnecessary.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- .../media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c +4 -7
@@ -202,7 +202,9 @@ static int rzv2h_ivc_probe(struct platform_device *pdev)pm_runtime_set_autosuspend_delay (dev,2000 );pm_runtime_use_autosuspend (dev); -pm_runtime_enable (dev); + ret =devm_pm_runtime_enable (dev); +if (ret) +return ret; ivc->irqnum =platform_get_irq (pdev,0 );if (ivc->irqnum <0 )
@@ -210,14 +212,9 @@ static int rzv2h_ivc_probe(struct platform_device *pdev) ret =rzv2h_ivc_initialise_subdevice (ivc);if (ret) - goto err_disable_pm_runtime; +return ret;return 0 ; - -err_disable_pm_runtime: -pm_runtime_disable (dev); - -return ret; }static void rzv2h_ivc_remove (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/1257 media: v4l2-isp: reject zero-sized parameter blocks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit 43ba38e1e02bbfbe99d3c4145df3c24797586c97 ]
v4l2_isp_params_validate_buffer() walks the blocks of a parameters buffer by adding block->size to the current offset. A block whose type_info[] entry is an uninitialised hole passes every check on the way there: a size of 0 is not caught by the block->size > buffer_size test, and the match against the type info size compares 0 with the hole's own 0 and passes as well. The walk then makes no forward progress and loops forever.
Drivers build their type_info[] arrays with designated initialisers indexed by their block type enumeration, so an enumerator left without an entry leaves a zeroed hole rather than failing the build. Drivers call the validator from vb2 .buf_prepare, so such a hole turns a VIDIOC_QBUF on the parameters video device into an unkillable task spinning with the queue mutex held.
Reject a block whose type info entry is empty. The driver does not implement the type, so it cannot tell whether the block content is meaningful, and accepting it silently would leave that content unconstrained until a later kernel implements the type and starts validating it. The size match then always runs against a non-zero size, and no block can advance the walk by zero.
--- drivers/media/v4l2-core/v4l2-isp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-isp.c +14 -1
@@ -99,12 +99,25 @@ int v4l2_isp_params_validate_buffer(struct device *dev, struct vb2_buffer *vb,return -EINVAL ; } +/* +* An empty type info entry denotes a block type the driver +* does not support. Reject the buffer instead of ignoring the +* block: accepting it silently would let userspace fill it +* with data that a later kernel, once it implements the type, +* would validate and possibly reject. +*/ + info = &type_info[block->type]; +if (!info->size) { +dev_dbg (dev,"Unsupported block type %u at offset %zu\n" , + block->type, block_offset); +return -EINVAL ; + } +/* * Match the block reported size against the type info provided * one, but allow the block to only contain the header in * case it is going to be disabled. */ - info = &type_info[block->type];if (block->size != info->size && (!(block->flags &V4L2_ISP_PARAMS_FL_BLOCK_DISABLE ) || block->size !=sizeof (*block))) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/1257 media: mali-c55: fail power-on when safe stop times out
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 73d3d5c97c9c0d71ef9ac6bc72520fb1dc547702 ]
The power-on path requests safe stop to establish a non-streaming state but ignores the polling result and publishes runtime resume success.
Power the block back off and propagate a safe-stop timeout.
--- drivers/media/platform/arm/mali-c55/mali-c55-core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/platform/arm/mali-c55/mali-c55-core.c +7 -2
@@ -730,8 +730,13 @@ static int __mali_c55_power_on(struct mali_c55 *mali_c55)/* Set safe stop to ensure we're in a non-streaming state */ mali_c55_write (mali_c55,MALI_C55_REG_INPUT_MODE_REQUEST ,MALI_C55_INPUT_SAFE_STOP ); -readl_poll_timeout (mali_c55->base +MALI_C55_REG_MODE_STATUS , - val, !val,10 *USEC_PER_MSEC ,250 *USEC_PER_MSEC ); + ret =readl_poll_timeout (mali_c55->base +MALI_C55_REG_MODE_STATUS , + val, !val,10 *USEC_PER_MSEC ,250 *USEC_PER_MSEC ); +if (ret) { +dev_err (mali_c55->dev,"safe stop timed out\n" ); +__mali_c55_power_off (mali_c55); +return ret; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/1257 media: mali-c55: Free the ISP control handler on unregister
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit 5f09aaf3fbc0d592df65c1aaa2ad113e56940070 ]
mali_c55_isp_init_controls() initialises isp->handler and adds the capabilities control, but mali_c55_unregister_isp() never frees it. Neither v4l2_device_unregister_subdev() nor v4l2_subdev_cleanup() touches sd->ctrl_handler, so the handler and its control are leaked on every unbind or module removal. The probe error path already frees it, and the TPG subdevice does so in its own unregister function.
--- drivers/media/platform/arm/mali-c55/mali-c55-isp.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/arm/mali-c55/mali-c55-isp.c +1 -0
@@ -641,6 +641,7 @@ void mali_c55_unregister_isp(struct mali_c55 *mali_c55)mutex_destroy (&isp->capture_lock);v4l2_device_unregister_subdev (&isp->sd); +v4l2_ctrl_handler_free (&isp->handler);v4l2_subdev_cleanup (&isp->sd);media_entity_cleanup (&isp->sd.entity); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/1257 media: mali-c55: Check the parameters buffer address before copying
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit 901d72d26b6dc135a41e3901b4690de124665d18 ]
mali_c55_params_buf_prepare() copies the parameters buffer supplied by userspace into the driver's scratch buffer, using the result of vb2_plane_vaddr() as the source without checking it. The queue accepts VB2_DMABUF, and vb2_dc_vaddr() returns NULL for an exporter that cannot be vmapped, so the memcpy() dereferences NULL.
Reject the buffer at prepare time instead.
--- drivers/media/platform/arm/mali-c55/mali-c55-params.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/arm/mali-c55/mali-c55-params.c +3 -0
@@ -710,6 +710,9 @@ static int mali_c55_params_buf_prepare(struct vb2_buffer *vb)struct mali_c55 *mali_c55 = params->mali_c55;int ret; +if (!config) +return -EFAULT ; + ret =v4l2_isp_params_validate_buffer_size (mali_c55->dev, vb,v4l2_isp_buffer_size (MALI_C55_PARAMS_MAX_SIZE ));if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/1257 media: mali-c55: Check the statistics buffer address before filling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit 907273d00dabc60494a691907cfb9bb9bb50ab2f ]
mali_c55_stats_cpu_read() copies the metering registers into the buffer returned by vb2_plane_vaddr() without checking it. As for the parameters queue, a DMABUF whose exporter cannot be vmapped yields NULL, and the memcpy_fromio() then dereferences it from the threaded interrupt handler.
Report the failure to mali_c55_stats_fill_buffer() and complete the buffer with VB2_BUF_STATE_ERROR.
--- .../platform/arm/mali-c55/mali-c55-stats.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/platform/arm/mali-c55/mali-c55-stats.c +13 -5
@@ -200,9 +200,9 @@ static const struct vb2_ops mali_c55_stats_vb2_ops = { .stop_streaming = mali_c55_stats_stop_streaming, }; -static void mali_c55_stats_cpu_read (struct mali_c55_stats *stats, -struct mali_c55_stats_buf *buf, -enum mali_c55_config_spaces cfg_space) +static int mali_c55_stats_cpu_read (struct mali_c55_stats *stats, +struct mali_c55_stats_buf *buf, +enum mali_c55_config_spaces cfg_space) {struct mali_c55 *mali_c55 = stats->mali_c55;const void __iomem *src;
@@ -211,12 +211,18 @@ static void mali_c55_stats_cpu_read(struct mali_c55_stats *stats, src = mali_c55->base +MALI_C55_REG_1024BIN_HIST ; dst =vb2_plane_vaddr (&buf->vb.vb2_buf,0 ); + +if (!dst) +return -EFAULT ; +memcpy_fromio (dst, src,MALI_C55_1024BIN_HIST_SIZE ); src = mali_c55->base + metering_space_addrs[cfg_space]; dst +=MALI_C55_1024BIN_HIST_SIZE ; length =sizeof (struct mali_c55_stats_buffer ) -MALI_C55_1024BIN_HIST_SIZE ;memcpy_fromio (dst, src, length); + +return 0 ; } void mali_c55_stats_fill_buffer(struct mali_c55 *mali_c55,
@@ -224,6 +230,7 @@ void mali_c55_stats_fill_buffer(struct mali_c55 *mali_c55, {struct mali_c55_stats *stats = &mali_c55->stats;struct mali_c55_stats_buf *buf =NULL ; +int ret;spin_lock (&stats->buffers.lock);if (!list_empty (&stats->buffers.queue)) {
@@ -239,8 +246,9 @@ void mali_c55_stats_fill_buffer(struct mali_c55 *mali_c55, buf->vb.sequence = mali_c55->isp.frame_sequence; buf->vb.vb2_buf.timestamp =ktime_get_boottime_ns (); -mali_c55_stats_cpu_read (stats, buf, cfg_space); -vb2_buffer_done (&buf->vb.vb2_buf,VB2_BUF_STATE_DONE ); + ret =mali_c55_stats_cpu_read (stats, buf, cfg_space); +vb2_buffer_done (&buf->vb.vb2_buf, + ret ?VB2_BUF_STATE_ERROR :VB2_BUF_STATE_DONE ); }void mali_c55_unregister_stats (struct mali_c55 *mali_c55)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/1257 media: mali-c55: Ignore disconnected queues when checking readiness
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9cfc1aca0781ce08e307b6c9dd617d37021544a8 ]
mali_c55_pipeline_ready() waits for every video queue to enter its start_streaming callback, regardless of whether its media link is enabled.
When libcamera uses the TPG, it disables the statistics and parameters links and queues only image buffers. Although STREAMON succeeds on the metadata nodes, videobuf2 never invokes their callbacks without queued buffers. The ISP and TPG are therefore never enabled and capture hangs.
An unused full-resolution or downscaled output can similarly prevent the pipeline from starting.
Only require queues connected through enabled media links to have started.
Use media_pad_remote_pad_first() to check the video node pads, retaining the capability check before accessing the optional downscale device.
The shared readiness check also keeps stream-off consistent: the first active queue to stop disables the ISP.
--- drivers/media/platform/arm/mali-c55/mali-c55-core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/media/platform/arm/mali-c55/mali-c55-core.c +8 -3
@@ -510,11 +510,16 @@ bool mali_c55_pipeline_ready(struct mali_c55 *mali_c55)struct mali_c55_params *params = &mali_c55->params;struct mali_c55_stats *stats = &mali_c55->stats; -return vb2_start_streaming_called (&fr->queue) && +/* Only wait for queues connected through enabled media links. */ +return (!media_pad_remote_pad_first (&fr->pad) || +vb2_start_streaming_called (&fr->queue)) && (!(mali_c55->capabilities &MALI_C55_GPS_DS_PIPE_FITTED ) || + !media_pad_remote_pad_first (&ds->pad) ||vb2_start_streaming_called (&ds->queue)) && -vb2_start_streaming_called (¶ms->queue) && -vb2_start_streaming_called (&stats->queue); + (!media_pad_remote_pad_first (¶ms->pad) || +vb2_start_streaming_called (¶ms->queue)) && + (!media_pad_remote_pad_first (&stats->pad) || +vb2_start_streaming_called (&stats->queue)); }static int mali_c55_check_hwcfg (struct mali_c55 *mali_c55)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/1257 media: tw686x: fix V4L2 device lifetime on probe failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit ce6c6dd632b3b4a2c2bfc9efd8f656f4d2137dbd ]
tw686x_video_init() registers the V4L2 device, which initializes its reference count. Successfully registered video devices take additional references to the V4L2 device as well.
The probe failure paths currently tear down the PCI resources and then free the channel arrays and the tw686x device directly. This bypasses the V4L2 device reference count and the tw686x_dev_release() callback.
If a video device still holds a reference, its eventual release will drop a reference to the already freed V4L2 device. Even when no extra references remain, directly freeing the device bypasses the lifetime management established by v4l2_device_register().
After cleaning up the PCI resources, check whether the V4L2 device was registered. If so, mark the hardware unavailable and drop the driver's V4L2 device reference, letting tw686x_dev_release() free the backing objects when the final reference is released. Keep the existing direct free path for failures that occur before V4L2 device registration.
This issue was found by manual code inspection.
--- drivers/media/pci/tw686x/tw686x-core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/pci/tw686x/tw686x-core.c +10 -0
@@ -241,6 +241,7 @@ static int tw686x_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) {struct tw686x_dev *dev; +unsigned long flags;int err; dev =kzalloc_obj (*dev);
@@ -352,6 +353,15 @@ static int tw686x_probe(struct pci_dev *pci_dev,pci_release_regions (pci_dev); disable_pci:pci_disable_device (pci_dev); +if (dev->v4l2_dev.dev) { +spin_lock_irqsave (&dev->lock, flags); + dev->pci_dev =NULL ; +spin_unlock_irqrestore (&dev->lock, flags); + +v4l2_device_put (&dev->v4l2_dev); +return err; + } + free_audio:kfree (dev->audio_channels); free_video:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/1257 media: pvrusb2: Fix USB parent device leak in class_dev_create()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 02421d7278e4a62c3daf37ad6c45d4af96ee4252 ]
class_dev_create() stores a reference to the USB device obtained with get_device() in class_dev->parent, which class_dev_destroy() releases. When device_register() fails the function only drops class_dev, so the reference to the USB parent device is never released.
Drop the parent reference on the failure path as well.
--- drivers/media/usb/pvrusb2/pvrusb2-sysfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/pvrusb2/pvrusb2-sysfs.c +1 -0
@@ -633,6 +633,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp)if (ret) {pvr2_trace (PVR2_TRACE_ERROR_LEGS ,"device_register failed" ); +put_device (class_dev->parent);put_device (class_dev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/1257 media: rtl28xxu: fix SDR platform device leak
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 083a92996598a5080965f1baa84175082e14a45b ]
rtl2832u_tuner_attach() registers an rtl2832_sdr platform device, but does not unregister it if no driver is bound. It also does not take a reference on the bound driver module.
Unregister the platform device when no driver is bound or the module reference cannot be acquired. Drop the module reference in rtl28xxu_tuner_detach() before unregistering the device.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
--- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb-v2/rtl28xxu.c +12 -2
@@ -1391,8 +1391,16 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)"rtl2832_sdr" ,PLATFORM_DEVID_AUTO , &pdata, sizeof(pdata)); -if (IS_ERR (pdev) || pdev->dev.driver ==NULL ) +if (IS_ERR (pdev))break ; +if (!pdev->dev.driver) { +platform_device_unregister (pdev); +break ; + } +if (!try_module_get (pdev->dev.driver->owner)) { +platform_device_unregister (pdev); +break ; + } dev->platform_device_sdr = pdev;break ;default :
@@ -1426,8 +1434,10 @@ static int rtl28xxu_tuner_detach(struct dvb_usb_adapter *adap)/* remove platform SDR */ pdev = dev->platform_device_sdr; -if (pdev) +if (pdev) { +module_put (pdev->dev.driver->owner);platform_device_unregister (pdev); + }/* remove I2C tuner */ client = dev->i2c_client_tuner;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/1257 media: exynos4-is: Fix a race between s_stream(0) and the interrupt handler
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ginger Li <[email protected]>
[ Upstream commit c65eb69f8170975802ddbede84420553eb681d62 ]
fimc_lite_subdev_s_stream(on = 0) sets ST_FLITE_OFF outside of the fimc->slock protected region, and only then stops the capture in the hardware. flite_irq_handler() runs under fimc->slock and clears ST_FLITE_OFF, so an interrupt can be handled in between: the handler finds ST_FLITE_OFF already set, clears it and wakes up fimc->irq_queue before the capture has actually been stopped. The wait_event_timeout() right after it then returns immediately and the driver continues as if the capture had stopped.
Set ST_FLITE_OFF in the same critical section that stops the capture, as fimc_lite_stop_capture() already does.
--- drivers/media/platform/samsung/exynos4-is/fimc-lite.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/samsung/exynos4-is/fimc-lite.c +1 -2
@@ -1209,9 +1209,8 @@ static int fimc_lite_subdev_s_stream(struct v4l2_subdev *sd, int on)spin_unlock_irqrestore (&fimc->slock, flags); } }else { -set_bit (ST_FLITE_OFF , &fimc->state); -spin_lock_irqsave (&fimc->slock, flags); +set_bit (ST_FLITE_OFF , &fimc->state);flite_hw_capture_stop (fimc);spin_unlock_irqrestore (&fimc->slock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/1257 media: em28xx: fix double free in em28xx_alloc_urbs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaho Jiang <[email protected]>
[ Upstream commit fd427b8adae437cac78a2332241a03cac56e95c2 ]
When allocation of usb_bufs->buf[i] fails, em28xx_alloc_urbs() explicitly frees all items within usb_bufs->buf before calling em28xx_uninit_usb_xfer(), which also frees these items, causing them to be freed twice.
BUG: KASAN: double-free in usb_free_urb.part.0 (drivers/usb/core/urb.c:25 ./include/linux/kref.h:65 drivers/usb/core/urb.c:96) Free of addr ffff88802fd37c00 by task kworker/1:2/1182 Workqueue: events request_module_async Call Trace: kasan_report_invalid_free (mm/kasan/report.c:557) check_slab_allocation (mm/kasan/common.c:235) kfree (./include/linux/kasan.h:199 (discriminator 1) mm/slub.c:2693 (discriminator 1) mm/slub.c:6508 (discriminator 1) mm/slub.c:6801 (discriminator 1)) usb_free_urb.part.0 (drivers/usb/core/urb.c:25 ./include/linux/kref.h:65 drivers/usb/core/urb.c:96) usb_free_urb (drivers/usb/core/urb.c:95) em28xx_uninit_usb_xfer (drivers/media/usb/em28xx/em28xx-core.c:964) em28xx_alloc_urbs (drivers/media/usb/em28xx/em28xx-core.c:1076) em28xx_dvb_init (drivers/media/usb/em28xx/em28xx-dvb.c:1734 drivers/media/usb/em28xx/em28xx-dvb.c:1698) em28xx_init_extension (drivers/media/usb/em28xx/em28xx-core.c:1248) request_module_async (drivers/media/usb/em28xx/em28xx-cards.c:3685) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Allocated by task 1182: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) __kasan_kmalloc (mm/kasan/common.c:398 mm/kasan/common.c:415) __kmalloc_noprof (./include/linux/kasan.h:263 mm/slub.c:5414 mm/slub.c:5439) em28xx_alloc_urbs (./include/linux/slab.h:995 ./include/linux/slab.h:1312 drivers/media/usb/em28xx/em28xx-core.c:1081) em28xx_dvb_init (drivers/media/usb/em28xx/em28xx-dvb.c:1734 drivers/media/usb/em28xx/em28xx-dvb.c:1698) em28xx_init_extension (drivers/media/usb/em28xx/em28xx-core.c:1248) request_module_async (drivers/media/usb/em28xx/em28xx-cards.c:3685) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Freed by task 1182: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) kasan_save_free_info (mm/kasan/generic.c:584) __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285) kfree (./include/linux/kasan.h:235 mm/slub.c:2748 mm/slub.c:6508 mm/slub.c:6801) em28xx_alloc_urbs (drivers/media/usb/em28xx/em28xx-core.c:1084) em28xx_dvb_init (drivers/media/usb/em28xx/em28xx-dvb.c:1734 drivers/media/usb/em28xx/em28xx-dvb.c:1698) em28xx_init_extension (drivers/media/usb/em28xx/em28xx-core.c:1248) request_module_async (drivers/media/usb/em28xx/em28xx-cards.c:3685) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245)
Remove the explicit cleanup loop and let em28xx_uninit_usb_xfer() handle the cleanup.
--- drivers/media/usb/em28xx/em28xx-core.c | 3 --- 1 file changed, 3 deletions(-)
drivers/media/usb/em28xx/em28xx-core.c +0 -3
@@ -1080,9 +1080,6 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, usb_bufs->buf[i] =kzalloc (sb_size,GFP_KERNEL );if (!usb_bufs->buf[i]) { -for (i--; i >=0 ; i--) -kfree (usb_bufs->buf[i]); -em28xx_uninit_usb_xfer (dev, mode);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/1257 media: em28xx: fix inverted tuner capability check for VBI device
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher Snowhill <[email protected]>
[ Upstream commit a8296bfabd1112e690aad9acc7de3c431f39d0e6 ]
Commit 8e53399c63c3 ("media: em28xx: Add support for Empia em2828X bridge") changed the condition for setting V4L2_CAP_TUNER on the VBI device from "dev->tuner_type != TUNER_ABSENT" to a check of the video device's capabilities, but inverted it: the VBI node now advertises a tuner only when the video node does not have one.
On boards without a tuner (e.g. the MyGica iGrabber, card=105) the VBI device's device_caps therefore contain V4L2_CAP_TUNER, while the shared vidioc_querycap() correctly omits it from cap->capabilities. This trips the sanity check in v4l_querycap() whenever the VBI node is queried, for example by udev's v4l_id on every hotplug:
WARNING: drivers/media/v4l2-core/v4l2-ioctl.c:1119 at v4l_querycap+0xff/0x110 [videodev] (cap->capabilities & (vfd->device_caps | V4L2_CAP_DEVICE_CAPS)) != (vfd->device_caps | V4L2_CAP_DEVICE_CAPS)
It also leaves the tuner ioctls enabled on the VBI node of tuner-less boards and disables them on boards that do have a tuner.
Restore the intended logic so the VBI device has V4L2_CAP_TUNER exactly when the video device does.
--- drivers/media/usb/em28xx/em28xx-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/em28xx/em28xx-video.c +1 -1
@@ -3001,7 +3001,7 @@ static int em28xx_v4l2_init(struct em28xx *dev) v4l2->vbi_dev.queue->lock = &v4l2->vb_vbi_queue_lock; v4l2->vbi_dev.device_caps =V4L2_CAP_STREAMING |V4L2_CAP_READWRITE |V4L2_CAP_VBI_CAPTURE ; -if ((v4l2->vdev.device_caps &V4L2_CAP_TUNER ) ==0 ) +if (v4l2->vdev.device_caps &V4L2_CAP_TUNER ) v4l2->vbi_dev.device_caps |=V4L2_CAP_TUNER ;/* disable inapplicable ioctls */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/1257 dm: fix a bug in dm_accept_partial_bio
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit a279804752e6c767b7f9ecbb32a15bdfd2b80aea ]
dm-writecache doesn't work in pmem mode - mkfs.ext4 and the following fsck.ext4 fail with data corruption reported.
The commit 7dd76d1feec7 ("dm: improve bio splitting and associated IO accounting") introduced a latent bug in dm_accept_partial_bio - it set tio->io->sectors = n_sectors;. This is incorrect, according to the diagram in the source code at dm_accept_partial_bio, it should be the size of regions 1+2, not the region 2 alone.
The latent bug become real bug with the commit 8b211aaccb91 ("dm: add two stage requeue mechanism").
dm-writecache in pmem mode is the only target that actually advances bio with bio_advance and then calls dm_accept_partial_bio (so, the region 1 is non-empty). All the other targets call dm_accept_partial_bio with region 1 empty, so bug went unnoticed for so long.
--- drivers/md/dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm.c +1 -1
@@ -1350,7 +1350,7 @@ void dm_accept_partial_bio(struct bio *bio, unsigned int n_sectors)* for accounting but it is being reduced so update accordingly. */ dm_io_set_flag (io,DM_IO_WAS_SPLIT ); - io->sectors = n_sectors; + io->sectors = *tio->len_ptr; io->sector_offset =bio_sectors (io->orig_bio); }EXPORT_SYMBOL_GPL (dm_accept_partial_bio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/1257 dm-writecache: report I/O error if flush failed
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 78a6afc2999d26e5a30a56db77db34c22b88f5d5 ]
There was a bug that if writecache_flush fails due to I/O error, the error is not reported in the FUA bio. This commit fixes it.
--- drivers/md/dm-writecache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/md/dm-writecache.c +5 -2
@@ -1493,10 +1493,13 @@ static enum wc_map_op writecache_map_write(struct dm_writecache *wc, struct bio } }while (bio->bi_iter.bi_size); -if (unlikely (bio->bi_opf &REQ_FUA || wc->uncommitted_blocks >= wc->autocommit_blocks)) +if (unlikely (bio->bi_opf &REQ_FUA || wc->uncommitted_blocks >= wc->autocommit_blocks)) {writecache_flush (wc); -else +if (writecache_has_error (wc)) + bio->bi_status =BLK_STS_IOERR ; + }else {writecache_schedule_autocommit (wc); + }return WC_MAP_SUBMIT ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/1257 dm-writecache: fix a quirk in statistics
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit c1ab80af0d99a906b60b769f2e692c37d2db1323 ]
writecache_bio_copy_ssd() unconditionally adds the number of extra blocks in the merged bio to stats.writes_allocate. That is only correct when the entries were taken off the freelist.
When the function is called with search_used == true -- i.e. from the write_hits_uncommitted / write_hits_committed paths in writecache_map_write() -- the first entry was found in the rbtree and every following entry is picked up with rb_next(), so nothing is allocated at all. Accordingly the writes_allocate++ that accompanies a successful writecache_pop_from_freelist() is skipped for that case, but the batch accounting below still adds n - 1.
An in-place overwrite of n contiguous cached blocks therefore reports n - 1 allocations that never happened. Only the dmsetup status output is affected; there is no functional change.
--- drivers/md/dm-writecache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/dm-writecache.c +2 -1
@@ -1424,7 +1424,8 @@ static void writecache_bio_copy_ssd(struct dm_writecache *wc, struct bio *bio,dm_accept_partial_bio (bio, bio_size >>SECTOR_SHIFT ); wc->stats.writes += bio->bi_iter.bi_size >> wc->block_size_bits; - wc->stats.writes_allocate += (bio->bi_iter.bi_size - wc->block_size) >> wc->block_size_bits; +if (!search_used) + wc->stats.writes_allocate += (bio->bi_iter.bi_size - wc->block_size) >> wc->block_size_bits;if (unlikely (wc->uncommitted_blocks >= wc->autocommit_blocks)) { wc->uncommitted_blocks =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/1257 dm-writecache: fix a crash if we attempt to use non-dax device
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit b15dc73f60ebf02410bc7014ce34fb7fd1040045 ]
If we specify a non-DAX device as a cache device in the 'P' mode, dm-writecache crashes on NULL pointer dereference inside dax_synchronous.
Note that this is not a security bug because only root can trigger it.
--- drivers/md/dm-writecache.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/md/dm-writecache.c +5 -0
@@ -2502,6 +2502,11 @@ static int writecache_ctr(struct dm_target *ti, unsigned int argc, char **argv) }if (WC_MODE_PMEM (wc)) { +if (!wc->ssd_dev->dax_dev) { + r = -EOPNOTSUPP ; + ti->error ="Cache device is not a DAX device" ; + goto bad; + }if (!dax_synchronous (wc->ssd_dev->dax_dev)) { r = -EOPNOTSUPP ; ti->error ="Asynchronous persistent memory not supported as pmem cache" ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/1257 dm-writecache: fix uncommitted_blocks underflow
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 8a0cc5f3446a324b13f62020eeddb32d6ba1c2db ]
Revert the commit 39495b12ef1cf602e6abd350dce2ef4199906531
writecache_bio_copy_ssd sets wc->uncommitted_blocks = 0; and then queues the flush work: queue_work(wc->writeback_wq, &wc->flush_work);
It may be possible that discard is dispatched in this window, and the discard would decrement wc->uncommitted_blocks to -1U.
Note that this bug is benign - wc->uncommitted_blocks is only used to trigged autocommit, so decrementing it to -1U will trigger a spurious autocommit, but won't cause any data corruption.
--- drivers/md/dm-writecache.c | 2 -- 1 file changed, 2 deletions(-)
drivers/md/dm-writecache.c +0 -2
@@ -899,8 +899,6 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_ } discarded_something = true; } -if (!writecache_entry_is_committed (wc, e)) - wc->uncommitted_blocks--;writecache_free_entry (wc, e); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/1257 dm-writecache: fix REQ_FUA processing
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit c0df022cb0fa2bbee74bd9b90c66790bcd4e3050 ]
REQ_FUA did not flush metadata in SSD mode, this commit fixes it.
--- drivers/md/dm-writecache.c | 45 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-)
drivers/md/dm-writecache.c +35 -10
@@ -194,6 +194,7 @@ struct dm_writecache {struct task_struct *endio_thread;struct task_struct *flush_thread; +spinlock_t flush_list_lock;struct bio_list flush_list;struct dm_kcopyd_client *dm_kcopyd;
@@ -1288,9 +1289,11 @@ static int writecache_flush_thread(void *data)struct bio *bio;wc_lock (wc); +spin_lock_irq (&wc->flush_list_lock); bio =bio_list_pop (&wc->flush_list);if (!bio) {set_current_state (TASK_INTERRUPTIBLE ); +spin_unlock_irq (&wc->flush_list_lock);wc_unlock (wc);if (unlikely (kthread_should_stop ())) {
@@ -1301,6 +1304,7 @@ static int writecache_flush_thread(void *data)schedule ();continue ; } +spin_unlock_irq (&wc->flush_list_lock);if (bio_op (bio) ==REQ_OP_DISCARD ) { writecache_discard(wc, bio->bi_iter.bi_sector,
@@ -1322,9 +1326,12 @@ static int writecache_flush_thread(void *data)static void writecache_offload_bio (struct dm_writecache *wc,struct bio *bio) { +unsigned long flags; +spin_lock_irqsave (&wc->flush_list_lock, flags);if (bio_list_empty (&wc->flush_list))wake_up_process (wc->flush_thread);bio_list_add (&wc->flush_list, bio); +spin_unlock_irqrestore (&wc->flush_list_lock, flags); }enum wc_map_op {
@@ -1436,6 +1443,8 @@ static void writecache_bio_copy_ssd(struct dm_writecache *wc, struct bio *bio,static enum wc_map_op writecache_map_write (struct dm_writecache *wc,struct bio *bio) {struct wc_entry *e; +enum wc_map_op ret =WC_MAP_SUBMIT ; +bool need_flush = false; do { bool found_entry = false;
@@ -1472,7 +1481,8 @@ static enum wc_map_op writecache_map_write(struct dm_writecache *wc, struct biowritecache_map_remap_origin (wc, bio, e); wc->stats.writes_around += bio->bi_iter.bi_size >> wc->block_size_bits; wc->stats.writes += bio->bi_iter.bi_size >> wc->block_size_bits; -return WC_MAP_REMAP_ORIGIN ; + ret =WC_MAP_REMAP_ORIGIN ; + goto flush_pmem_and_ret; } wc->stats.writes_blocked_on_freelist++;writecache_wait_on_freelist (wc);
@@ -1486,21 +1496,25 @@ static enum wc_map_op writecache_map_write(struct dm_writecache *wc, struct bioif (WC_MODE_PMEM (wc)) {bio_copy_block (wc, bio,memory_data (wc, e)); wc->stats.writes++; + need_flush = true; }else {writecache_bio_copy_ssd (wc, bio, e, search_used);return WC_MAP_REMAP ; } }while (bio->bi_iter.bi_size); -if (unlikely (bio->bi_opf &REQ_FUA || wc->uncommitted_blocks >= wc->autocommit_blocks)) { -writecache_flush (wc); -if (writecache_has_error (wc)) - bio->bi_status =BLK_STS_IOERR ; - }else { -writecache_schedule_autocommit (wc); +flush_pmem_and_ret: +if (need_flush) { +if (unlikely (bio->bi_opf &REQ_FUA || wc->uncommitted_blocks >= wc->autocommit_blocks)) { +writecache_flush (wc); +if (writecache_has_error (wc)) + ret =WC_MAP_ERROR ; + }else { +writecache_schedule_autocommit (wc); + } } -return WC_MAP_SUBMIT ; +return ret; }static enum wc_map_op writecache_map_flush (struct dm_writecache *wc,struct bio *bio)
@@ -1590,7 +1604,10 @@ static int writecache_map(struct dm_target *ti, struct bio *bio)case WC_MAP_REMAP :/* make sure that writecache_end_io decrements bio_in_progress: */ - bio->bi_private = (void *)1 ; +if (unlikely (bio->bi_opf &REQ_FUA ) &&bio_op (bio) ==REQ_OP_WRITE ) + bio->bi_private = (void *)3 ; +else + bio->bi_private = (void *)1 ;atomic_inc (&wc->bio_in_progress[bio_data_dir (bio)]);wc_unlock (wc);return DM_MAPIO_REMAPPED ;
@@ -1620,12 +1637,19 @@ static int writecache_end_io(struct dm_target *ti, struct bio *bio, blk_status_t {struct dm_writecache *wc = ti->private; -if (bio->bi_private == (void *)1 ) { +if (bio->bi_private == (void *)1 || bio->bi_private == (void *)3 ) {int dir =bio_data_dir (bio); +bool fua = bio->bi_private == (void *)3 ;if (atomic_dec_and_test (&wc->bio_in_progress[dir]))if (unlikely (waitqueue_active (&wc->bio_in_progress_wait[dir])))wake_up (&wc->bio_in_progress_wait[dir]); + +if (fua &&likely (*status ==BLK_STS_OK )) { + bio->bi_private =NULL ; +writecache_offload_bio (wc, bio); +return DM_ENDIO_INCOMPLETE ; + } }else if (bio->bi_private == (void *)2 ) {dm_iot_io_end (&wc->iot,1 ); }
@@ -2522,6 +2546,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned int argc, char **argv) wc->memory_map_size -= (uint64_t )wc->start_sector <<SECTOR_SHIFT ; +spin_lock_init (&wc->flush_list_lock);bio_list_init (&wc->flush_list); wc->flush_thread =kthread_run (writecache_flush_thread, wc,"dm_writecache_flush" );if (IS_ERR (wc->flush_thread)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/1257 KVM: arm64: Fix MMFR0 TGRAN advertisement for pVMs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit 6c29285e78b5e4811145ebda382ac0ba732ce56a ]
Protected VM ID register emulation leaves unlisted fields at 0. This creates two issues for TGRAN:
* TGRAN16: 0 means non-implemented. It prevents 16KB protected VMs from booting even when the hardware supports it.
* TGRAN4|TGRAN64: 0 means implemented. This may falsely advertise the feature even when the hardware does not support it.
Advertise all the TGRAN fields in pvmid_aa64mmfr0 so that the hardware support is properly propagated.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +3 -0
@@ -121,6 +121,9 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr0[] = {MAX_FEAT (ID_AA64MMFR0_EL1 ,SNSMEM ,IMP ),MAX_FEAT (ID_AA64MMFR0_EL1 ,BIGENDEL0 ,IMP ),MAX_FEAT (ID_AA64MMFR0_EL1 ,EXS ,IMP ), +MAX_FEAT (ID_AA64MMFR0_EL1 ,TGRAN4 ,IMP ), +MAX_FEAT (ID_AA64MMFR0_EL1 ,TGRAN16 ,IMP ), +MAX_FEAT (ID_AA64MMFR0_EL1 ,TGRAN64 ,IMP ), FEAT_END };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/1257 pps: generators: stop the generator on unregister
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danish Khateeb <[email protected]>
[ Upstream commit 3e75af9f41c7509884d0955245dec2b791287e8c ]
Both generator drivers stop their timer and then call pps_gen_unregister_source(): pps_gen_tio_remove() cancels its hrtimer and disables the TIO, and pps_gen_dummy_exit() deletes its timer. But /dev/pps-genN and the sysfs "enable" attribute are still there until the unregister, and a PPS_GEN_SETENABLE or a write to "enable" in between starts the timer again. Nothing stops it after that: TIO's hrtimer keeps running in the devm memory freed by the unbind, and the dummy's timer is left in the unloaded module.
The drivers can't avoid this by unregistering first, as TIO's timer callback uses pps_gen, which the unregister may free.
Stop the generator in pps_gen_unregister_cdev() instead, under info_lock after the device and its sysfs files are gone, when nothing can enable it again. pps_gen_unregister_source() then also does what its kernel-doc says: "it disables the generator so no pulses are generated anymore".
--- drivers/pps/generators/pps_gen.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/pps/generators/pps_gen.c +10 -1
@@ -228,9 +228,18 @@ static void pps_gen_unregister_cdev(struct pps_gen_device *pps_gen)* An open file keeps pps_gen around, but the driver may free info as * soon as we return. The sysfs files are gone now, so wait for the * ioctls using info and make later ones fail. +* +* The driver may have stopped the generator before calling us, but +* userspace could have enabled it again since. Nothing can enable it +* after this point, so stop it here for good. */ -scoped_guard (mutex, &pps_gen->info_lock) + scoped_guard(mutex, &pps_gen->info_lock) { +if (pps_gen->enabled) { + pps_gen->info->enable (pps_gen, false); + pps_gen->enabled = false; + } pps_gen->info =NULL ; + }put_device (&pps_gen->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/1257 block: drop the cached plug time when blk_add_rq_to_plug() flushes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasileios Almpanis <[email protected]>
[ Upstream commit e0f2224433b15a57125d6ac5d46182f99c6c9d08 ]
blk_time_get_ns() caches the current time in the task's plug. The idea is that the cache lives for one plug and is dropped when the plug is flushed. __blk_flush_plug() and finish_task_switch() do that.
blk_add_rq_to_plug() also flushes, when the plug has too many requests or the last request is at least BLK_PLUG_FLUSH_SIZE. But it calls blk_mq_flush_plug_list() directly and never drops the cached time. So a task that keeps submitting without sleeping stamps every request after that with the time first cached in the plug. start_time_ns and io_start_time_ns are stale and the disk stats charge each request for the whole time since the plug began.
Drop the cached time after the flush, same as __blk_flush_plug() does.
--- block/blk-mq.c | 1 + 1 file changed, 1 insertion(+)
block/blk-mq.c +1 -0
@@ -1397,6 +1397,7 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq) (!blk_queue_nomerges(rq->q) && blk_rq_bytes(last) >= BLK_PLUG_FLUSH_SIZE)) {blk_mq_flush_plug_list (plug, false); +blk_plug_invalidate_ts (); last =NULL ;trace_block_plug (rq->q); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/1257 block: amiflop: synchronize flush timer before track flush
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9690943353cec1690a715e000ba6a74e5139f530 ]
The amiflop track buffer is shared with the timer callback. timer_delete() does not wait for an in-flight callback, and that callback can rearm itself when it cannot acquire the floppy controller. A synchronous track flush can therefore race with the callback.
Stop the timer before synchronous track writes and use timer_delete_sync() to wait for any callback already running. Keep callback rearming disabled until the write is complete. Apply this to the FDFMTTRK path as well.
FDFLUSH, FDFMTTRK and close-time flushes run outside the blk-mq request callback. Freeze their queues so an in-flight request cannot change the shared track buffer while it is encoded and written. Restart the timer if a track remains dirty after a failed flush.
--- drivers/block/amiflop.c | 71 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 8 deletions(-)
drivers/block/amiflop.c +63 -8
@@ -265,6 +265,8 @@ static struct fd_data_type data_types[] = {static struct amiga_floppy_struct unit[FD_MAX_UNITS ];static struct timer_list flush_track_timer[FD_MAX_UNITS ]; +static DEFINE_SPINLOCK (flush_track_timer_lock); +static bool flush_track_timer_stopped[FD_MAX_UNITS ];static struct timer_list post_write_timer;static unsigned long post_write_timer_drive;static struct timer_list motor_on_timer;
@@ -1370,11 +1372,22 @@ static void flush_track_callback(struct timer_list *timer)sizeof (flush_track_timer[0 ]); nr&=3 ; +spin_lock (&flush_track_timer_lock); +if (flush_track_timer_stopped[nr]) { +spin_unlock (&flush_track_timer_lock); +return ; + } +spin_unlock (&flush_track_timer_lock); + writefromint =1 ;if (!try_fdc (nr)) {/* we might block in an interrupt, so try again later */ - flush_track_timer[nr].expires = jiffies +1 ; -add_timer (flush_track_timer + nr); +spin_lock (&flush_track_timer_lock); +if (!flush_track_timer_stopped[nr]) { + flush_track_timer[nr].expires = jiffies +1 ; +add_timer (flush_track_timer + nr); + } +spin_unlock (&flush_track_timer_lock);return ; }get_fdc (nr);
@@ -1421,6 +1434,35 @@ static int non_int_flush_track (unsigned long nr)return 1 ; } +static void flush_track_timer_stop (unsigned int drive) +{ +unsigned long flags; + +spin_lock_irqsave (&flush_track_timer_lock, flags); + flush_track_timer_stopped[drive] = true; +spin_unlock_irqrestore (&flush_track_timer_lock, flags); + +timer_delete_sync (flush_track_timer + drive); +} + +static void flush_track_timer_start (unsigned int drive) +{ +unsigned long flags; + +spin_lock_irqsave (&flush_track_timer_lock, flags); + flush_track_timer_stopped[drive] = false; +if (unit[drive].dirty) +mod_timer (flush_track_timer + drive, jiffies +1 ); +spin_unlock_irqrestore (&flush_track_timer_lock, flags); +} + +static void flush_track_timer_sync (unsigned int drive) +{ +flush_track_timer_stop (drive); +non_int_flush_track (drive); +flush_track_timer_start (drive); +} +static int get_track (int drive,int track) {int error, errcnt;
@@ -1435,8 +1477,7 @@ static int get_track(int drive, int track) }if (unit[drive].dirty ==1 ) { -timer_delete (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive); } errcnt =0 ;while (errcnt <MAX_ERRORS ) {
@@ -1562,6 +1603,12 @@ static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode,case FDFMTTRK :if (param < p->type->tracks * p->type->heads) { +flush_track_timer_stop (drive); +if (unit[drive].dirty ==1 && + !non_int_flush_track (drive)) { +flush_track_timer_start (drive); +return -EIO ; + }get_fdc (drive);if (fd_seek (drive,param) !=0 ){ memset(p->trackbuf, FD_FILL_BYTE,
@@ -1570,6 +1617,7 @@ static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode, }floppy_off (drive);rel_fdc (); +flush_track_timer_start (drive); }else return -EINVAL ;
@@ -1591,8 +1639,7 @@ static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode,case FDDEFPRM :return -EINVAL ;case FDFLUSH :/* unconditionally, even if not needed */ -timer_delete (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive);break ;#ifdef RAW_IOCTL case IOCTL_RAW_TRACK :
@@ -1611,9 +1658,15 @@ static int fd_ioctl(struct block_device *bdev, blk_mode_t mode, unsigned int cmd, unsigned long param) { int ret; +unsigned int memflags =0 ; +bool freeze_queue = cmd ==FDFMTTRK || cmd ==FDFLUSH ;mutex_lock (&amiflop_mutex); +if (freeze_queue) + memflags =blk_mq_freeze_queue (bdev->bd_disk->queue); ret =fd_locked_ioctl (bdev, mode, cmd, param); +if (freeze_queue) +blk_mq_unfreeze_queue (bdev->bd_disk->queue, memflags);mutex_unlock (&amiflop_mutex);return ret;
@@ -1711,11 +1764,12 @@ static void floppy_release(struct gendisk *disk) {struct amiga_floppy_struct *p = disk->private_data;int drive = p - unit; +unsigned int memflags;mutex_lock (&amiflop_mutex); + memflags =blk_mq_freeze_queue (disk->queue);if (unit[drive].dirty ==1 ) { -timer_delete (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive); }if (!fd_ref[drive]--) {
@@ -1725,6 +1779,7 @@ static void floppy_release(struct gendisk *disk)#ifdef MODULE floppy_off (drive);#endif +blk_mq_unfreeze_queue (disk->queue, memflags);mutex_unlock (&amiflop_mutex); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/1257 arm64: dts: qcom: shikra: Remove cdsp compute-cb@9
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anandu Krishnan E <[email protected]>
[ Upstream commit 90ae3eb55ad64dc05ab7ad4a667c921d0504ccc4 ]
Remove the context bank compute-cb@9 as it is a secure context bank used for secure use cases. Secure use case support is not currently implemented upstream, and allowing other use cases to be offloaded onto this context bank results in an SMMU fault.
--- arch/arm64/boot/dts/qcom/shikra.dtsi | 6 ------ 1 file changed, 6 deletions(-)
arch/arm64/boot/dts/qcom/shikra.dtsi +0 -6
@@ -1948,12 +1948,6 @@ compute-cb@6 { reg = <6>; iommus = <&apps_smmu 0x0206 0x0000>; }; - - compute-cb@9 { - compatible = "qcom,fastrpc-compute-cb"; - reg = <9>; - iommus = <&apps_smmu 0x0209 0x0000>; - }; }; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/1257 PCI: Disable MSI for ULi M1575 EHCI controller
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <[email protected]>
[ Upstream commit 5f30217ec296fb5742f6fd306586dbca5b81b4eb ]
With MSI, the ULi M1575 EHCI controller (10b9:5239) intermittently stops executing its asynchronous schedule. Control transfers time out ("device not accepting address", "device descriptor read/64"), the port is handed to the companion OHCI controller, and the device ends up at full speed. On a configured hub the stall shows up as hub descriptor and status read failures. Only re-initializing the controller recovers it.
On a Sun Ultra 45, 65 of 800 controller initializations stalled with MSI and none of 200 with INTx. Each initialization is an unbind and bind of ehci-pci on the EHCI function, with MSI or INTx selected through its msi_bus attribute; with this quirk, 0 of 100 cycles of the same loop stalled. The stall reproduces on a kernel that already contains commit 0b60557230ad ("usb: ehci: Prevent missed ehci interrupts with edge-triggered MSI").
The OHCI functions (10b9:5237) keep MSI. They showed no stall, and the hub enumerated through them on MSI during the EHCI failures, so only the EHCI function is quirked.
The illumos EHCI driver also disables MSI on this chip, in ehci_register_intrs_and_init_mutex() in usr/src/uts/common/io/usb/hcd/ehci/ehci_util.c.
Until USB HCDs started trying MSI first in v5.9, the controller always used INTx. Disable MSI so it uses INTx again on this chipset.
--- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/quirks.c +2 -0
@@ -1945,6 +1945,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4388, quirk_no_msi);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ATI ,0x4389 , quirk_no_msi);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ATI ,0x438a , quirk_no_msi);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ATI ,0x438b , quirk_no_msi); +/* ULi M1575 EHCI (10b9:5239): MSI stalls the async schedule */ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AL ,0x5239 , quirk_no_msi);static void quirk_pcie_mch (struct pci_dev *pdev) {
Signature · 1 line
2.53.0