6.12.119-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 298/1756 scsi: mpi3mr: Fix buffer overflow in BSG passthrough request copy
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 896abdd4d81f40575b05d593f7fe004935a6cf97 ]
The size of an incoming BSG request is checked using a variable that is narrower than the field it is read from, so large values wrap and pass the check. The copy that follows then uses the full value and writes past the request buffer.
Widen the variable and copy only the amount that was checked.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -2
@@ -2300,7 +2300,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)long rval = -EINVAL ;struct mpi3mr_ioc *mrioc =NULL ;u8 *mpi_req =NULL , *sense_buff_k =NULL ; -u8 mpi_msg_size =0 ; +u32 mpi_msg_size =0 ;struct mpi3mr_bsg_packet *bsg_req =NULL ;struct mpi3mr_bsg_mptcmd *karg;struct mpi3mr_buf_entry *buf_entries =NULL ;
@@ -2453,7 +2453,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) rval = -EINVAL ; goto out; } -memcpy (mpi_req, sgl_iter, buf_entries->buf_len); +memcpy (mpi_req, sgl_iter, mpi_msg_size);break ;default : invalid_be =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/1756 scsi: mpi3mr: Fix out-of-bounds read when copying BSG MPI requests
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9fac4cbd66d852958e8a8d0952eb57f8554ce83b ]
The MPI request is copied out of the caller supplied payload without first checking that the requested amount is actually present, so the copy can read past the end of the payload buffer.
Check the range before copying.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_app.c +8 -0
@@ -2453,6 +2453,14 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) rval = -EINVAL ; goto out; } +if (sgl_iter + mpi_msg_size > + dout_buf + job->request_payload.payload_len) { +dprint_bsg_err (mrioc,"%s: MPI request buf exceeds dout_buf\n" , + __func__); +mutex_unlock (&mrioc->bsg_cmds.mutex); + rval = -EINVAL ; + goto out; + }memcpy (mpi_req, sgl_iter, mpi_msg_size);break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 300/1756 scsi: mpi3mr: Fix I/O block counter leak on admin request post failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 37e7d274272bc5e545e2d5f9261afa7f33f1cf49 ]
The per device I/O block counter is raised before a task management request is posted and only lowered once the request completes. If the post itself fails the counter stays raised and I/O to that device remains blocked.
Lower it on the failure path as well.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -0
@@ -2697,6 +2697,8 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)dprint_bsg_err (mrioc,"%s: posting bsg request is failed\n" , __func__); rval = -EAGAIN ; +if (block_io && stgt_priv) +atomic_dec (&stgt_priv->block_io); goto out_unlock; } wait_for_completion_timeout(&mrioc->bsg_cmds.done,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 301/1756 scsi: mpi3mr: Fix target device reference leak in BSG task management
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit f0ec04bdf6156ed2ae7d86a8819dafdd9383b705 ]
The target device lookup takes a reference, but it is only dropped inside a branch that also requires the SCSI target data to be set up. When it is not, the reference is leaked.
Drop the reference whenever the lookup succeeded.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +6 -4
@@ -2660,10 +2660,12 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) }if (block_io) { tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) { - stgt_priv = (struct mpi3mr_stgt_priv_data *) - tgtdev->starget->hostdata; -atomic_inc (&stgt_priv->block_io); +if (tgtdev) { +if (tgtdev->starget && tgtdev->starget->hostdata) { + stgt_priv = (struct mpi3mr_stgt_priv_data *) + tgtdev->starget->hostdata; +atomic_inc (&stgt_priv->block_io); + }mpi3mr_tgtdev_put (tgtdev); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 302/1756 scsi: mpi3mr: Fix buffer overflow when caching log data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9ff1af19c488efad66f2b803eefa0abd5fdac8f4 ]
Each log data slot holds a header followed by the payload, but the copy was sized against the whole slot and so wrote one header length past the end of it. Subtracting the header on its own is not enough either, because the entry size is derived from the controller reply size and can be smaller than the header.
Work out the payload room first and clamp the copy to it.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +8 -2
@@ -2862,7 +2862,8 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)void mpi3mr_app_save_logdata (struct mpi3mr_ioc *mrioc,char *event_data,u16 event_data_size) { -u32 index = mrioc->logdata_buf_idx, sz; +u32 index = mrioc->logdata_buf_idx; +size_t entry_payload_len, sz;struct mpi3mr_logdata_entry *entry;if (!(mrioc->logdata_buf))
@@ -2871,7 +2872,12 @@ void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data, entry = (struct mpi3mr_logdata_entry *) (mrioc->logdata_buf + (index * mrioc->logdata_entry_sz)); entry->valid_entry =1 ; - sz =min (mrioc->logdata_entry_sz, event_data_size); +if (mrioc->logdata_entry_sz >MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ ) + entry_payload_len = (size_t )mrioc->logdata_entry_sz - +MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ ; +else + entry_payload_len =0 ; + sz =min_t (size_t, entry_payload_len, event_data_size);memcpy (entry->data, event_data, sz); mrioc->logdata_buf_idx = ((++index) %MPI3MR_BSG_LOGDATA_MAX_ENTRIES );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 303/1756 scsi: mpi3mr: Fix out-of-bounds reply frame access
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit bcf0a5bed59acd5ae19d80e1f617c1a5b355af0b ]
The reply frame address reported on completion is only checked against the start and the end of the pool. An address near the top can pass the check while leaving less than a full frame, and an unaligned one resolves into the middle of a frame instead of the start of one.
Require a whole frame to fit and the address to be frame aligned.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_fw.c +6 -1
@@ -119,11 +119,16 @@ void mpi3mr_build_zero_len_sge(void *paddr)void *mpi3mr_get_reply_virt_addr (struct mpi3mr_ioc *mrioc,dma_addr_t phys_addr) { +u64 offset; +if (!phys_addr)return NULL ; + offset = phys_addr - mrioc->reply_buf_dma; +if ((phys_addr < mrioc->reply_buf_dma) || - (phys_addr > mrioc->reply_buf_dma_max_address)) + (phys_addr > mrioc->reply_buf_dma_max_address - mrioc->reply_sz) || +do_div (offset, mrioc->reply_sz))return NULL ;return mrioc->reply_buf + (phys_addr - mrioc->reply_buf_dma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 304/1756 scsi: mpi3mr: Fix out-of-bounds sense buffer access
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 7fea128f6b829ad834f21834d2605d28a45b903d ]
The sense buffer address reported on completion is turned into a virtual address with no range check, so an address outside the pool resolves to memory that does not belong to it.
Check that it lies within the pool and is correctly aligned.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_fw.c +10 -0
@@ -137,9 +137,19 @@ void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc,void *mpi3mr_get_sensebuf_virt_addr (struct mpi3mr_ioc *mrioc,dma_addr_t phys_addr) { +u64 offset; +if (!phys_addr)return NULL ; + offset = phys_addr - mrioc->sense_buf_dma; + +if (phys_addr < mrioc->sense_buf_dma || + (phys_addr > mrioc->sense_buf_dma + + (mrioc->num_sense_bufs *MPI3MR_SENSE_BUF_SZ ) -MPI3MR_SENSE_BUF_SZ ) || +do_div (offset,MPI3MR_SENSE_BUF_SZ )) +return NULL ; +return mrioc->sense_buf + (phys_addr - mrioc->sense_buf_dma); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 305/1756 scsi: mpi3mr: Fix out-of-bounds bitmap access during device removal
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 5dade59551d344d0308256edfef6bc3fb4202eb3 ]
Device handles reported by the controller are used to index the remove pending bitmap and to build a task management request without being compared against the maximum handle the controller reported.
Check the handle before using it.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +16 -1
@@ -2285,7 +2285,8 @@ static void mpi3mr_dev_rmhs_complete_iou(struct mpi3mr_ioc *mrioc,ioc_info (mrioc,"%s :dev removal handshake completed successfully: handle(0x%04x)\n" , __func__, drv_cmd->dev_handle); -clear_bit (drv_cmd->dev_handle, mrioc->removepend_bitmap); +if (drv_cmd->dev_handle < mrioc->facts.max_devhandle) +clear_bit (drv_cmd->dev_handle, mrioc->removepend_bitmap); }if (!list_empty (&mrioc->delayed_rmhs_list)) {
@@ -2399,6 +2400,20 @@ static void mpi3mr_dev_rmhs_send_tm(struct mpi3mr_ioc *mrioc, u16 handle,struct mpi3mr_tgt_dev *tgtdev =NULL ;unsigned long flags; +if (handle >= mrioc->facts.max_devhandle) { +ioc_err (mrioc,"dev_remove_hs: handle(0x%04x) >= max_devhandle(0x%04x)\n" , + handle, mrioc->facts.max_devhandle); +if (drv_cmd) { + cmd_idx = drv_cmd->host_tag -MPI3MR_HOSTTAG_DEVRMCMD_MIN ; + drv_cmd->state =MPI3MR_CMD_NOTUSED ; + drv_cmd->callback =NULL ; + drv_cmd->dev_handle =MPI3MR_INVALID_DEV_HANDLE ; + drv_cmd->retry_count =0 ; +clear_bit (cmd_idx, mrioc->devrem_bitmap); + } +return ; + } +spin_lock_irqsave (&mrioc->tgtdev_lock, flags); tgtdev =__mpi3mr_get_tgtdev_by_handle (mrioc, handle);if (tgtdev && (iou_rc ==MPI3_CTRL_OP_REMOVE_DEVICE ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 306/1756 scsi: mpi3mr: Fix target device reference leak in device removal handshake
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit a04b0f3a17e32aa449fd896163a7b40efc29c4f5 ]
The device removal handshake looks up the target device to update its state but never drops the reference that the lookup takes.
Drop it once the state has been updated.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_os.c +3 -0
@@ -2420,6 +2420,9 @@ static void mpi3mr_dev_rmhs_send_tm(struct mpi3mr_ioc *mrioc, u16 handle, tgtdev->state =MPI3MR_DEV_REMOVE_HS_STARTED ;spin_unlock_irqrestore (&mrioc->tgtdev_lock, flags); +if (tgtdev) +mpi3mr_tgtdev_put (tgtdev); +if (drv_cmd) goto issue_cmd; do {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 307/1756 scsi: mpi3mr: Fix out-of-bounds read in SAS topology change events
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9e220ce4bd0468e47cc9eea07e40799ebae6eda8 ]
The number of entries in a SAS topology change event is used to walk the entry array without being compared against the amount of event data that was received, so the walk can run past the end of the buffer.
Work out how many entries the payload can hold and skip the event if it claims more.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +19 -3
@@ -2713,12 +2713,28 @@ static void mpi3mr_sastopochg_evt_th(struct mpi3mr_ioc *mrioc,struct mpi3_event_data_sas_topology_change_list *topo_evt = (struct mpi3_event_data_sas_topology_change_list *)event_reply->event_data;int i; -u16 handle; -u8 reason_code; +u16 handle, avail_len; +u8 reason_code, max_entries, num_entries;struct mpi3mr_tgt_dev *tgtdev =NULL ;struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data =NULL ; -for (i =0 ; i < topo_evt->num_entries; i++) { + avail_len = event_reply->event_data_length *4 ; +if (avail_len < offsetof(struct mpi3_event_data_sas_topology_change_list , phy_entry)) { +ioc_err (mrioc,"SAS topology event: event data too small (%u bytes)\n" , + avail_len); +return ; + } + max_entries = (avail_len - + offsetof(struct mpi3_event_data_sas_topology_change_list , phy_entry)) / +sizeof (struct mpi3_event_sas_topo_phy_entry ); + num_entries = topo_evt->num_entries; +if (num_entries > max_entries) { +ioc_err (mrioc,"SAS topology event: num_entries(%d) exceeds max(%d)\n" , + num_entries, max_entries); +return ; + } + +for (i =0 ; i < num_entries; i++) { handle =le16_to_cpu (topo_evt->phy_entry[i].attached_dev_handle);if (!handle)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 308/1756 scsi: mpi3mr: Event processing debug improvement
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
[ Upstream commit 04f79c113ae77732e7e6674bd814e76c7a3453cf ]
Improve event process debugging. Implement more verbose event logging throughout the driver.
Stable-dep-of: 77554f01187d ("scsi: mpi3mr: Fix out-of-bounds read of event data")
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 67 ++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 17 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +50 -17
@@ -992,6 +992,10 @@ static int mpi3mr_report_tgtdev_to_host(struct mpi3mr_ioc *mrioc, goto out; } } +dprint_event_bh (mrioc, +"exposed target device with handle(0x%04x), perst_id(%d)\n" , + tgtdev->dev_handle, perst_id); + goto out; }else mpi3mr_report_tgtdev_to_sas_transport (mrioc, tgtdev); out:
@@ -1351,9 +1355,9 @@ static void mpi3mr_devstatuschg_evt_bh(struct mpi3mr_ioc *mrioc, (struct mpi3_event_data_device_status_change *)fwevt->event_data; dev_handle =le16_to_cpu (evtdata->dev_handle); -ioc_info (mrioc, -"%s :device status change: handle(0x%04x): reason code(0x%x)\n" , - __func__, dev_handle, evtdata->reason_code); +dprint_event_bh (mrioc, +"processing device status change event bottom half for handle(0x%04x), rc(0x%02x)\n" , + dev_handle, evtdata->reason_code);switch (evtdata->reason_code) {case MPI3_EVENT_DEV_STAT_RC_HIDDEN : delete =1 ;
@@ -1372,8 +1376,13 @@ static void mpi3mr_devstatuschg_evt_bh(struct mpi3mr_ioc *mrioc, } tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (!tgtdev) +if (!tgtdev) { +dprint_event_bh (mrioc, +"processing device status change event bottom half,\n" +"cannot identify target device for handle(0x%04x), rc(0x%02x)\n" , + dev_handle, evtdata->reason_code); goto out; + }if (uhide) { tgtdev->is_hidden =0 ;if (!tgtdev->host_exposed)
@@ -1413,12 +1422,17 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc, perst_id =le16_to_cpu (dev_pg0->persistent_id); dev_handle =le16_to_cpu (dev_pg0->dev_handle); -ioc_info (mrioc, -"%s :Device info change: handle(0x%04x): persist_id(0x%x)\n" , - __func__, dev_handle, perst_id); +dprint_event_bh (mrioc, +"processing device info change event bottom half for handle(0x%04x), perst_id(%d)\n" , + dev_handle, perst_id); tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (!tgtdev) +if (!tgtdev) { +dprint_event_bh (mrioc, +"cannot identify target device for device info\n" +"change event handle(0x%04x), perst_id(%d)\n" , + dev_handle, perst_id); goto out; + }mpi3mr_update_tgtdev (mrioc, tgtdev, dev_pg0, false);if (!tgtdev->is_hidden && !tgtdev->host_exposed)mpi3mr_report_tgtdev_to_host (mrioc, perst_id);
@@ -2019,8 +2033,11 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,mpi3mr_fwevt_del_from_list (mrioc, fwevt); mrioc->current_event = fwevt; -if (mrioc->stop_drv_processing) +if (mrioc->stop_drv_processing) { +dprint_event_bh (mrioc,"ignoring event(0x%02x) in the bottom half handler\n" +"due to stop_drv_processing\n" , fwevt->event_id); goto out; + }if (mrioc->unrecoverable) { dprint_event_bh(mrioc,
@@ -2032,6 +2049,9 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,if (!fwevt->process_evt) goto evt_ack; +dprint_event_bh (mrioc,"processing event(0x%02x) in the bottom half handler\n" , + fwevt->event_id); +switch (fwevt->event_id) {case MPI3_EVENT_DEVICE_ADDED : {
@@ -2804,6 +2824,9 @@ static void mpi3mr_devstatuschg_evt_th(struct mpi3mr_ioc *mrioc, goto out; dev_handle =le16_to_cpu (evtdata->dev_handle); +dprint_event_th (mrioc, +"device status change event top half with rc(0x%02x) for handle(0x%04x)\n" , + evtdata->reason_code, dev_handle);switch (evtdata->reason_code) {case MPI3_EVENT_DEV_STAT_RC_INT_DEVICE_RESET_STRT :
@@ -2827,8 +2850,12 @@ static void mpi3mr_devstatuschg_evt_th(struct mpi3mr_ioc *mrioc, } tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (!tgtdev) +if (!tgtdev) { +dprint_event_th (mrioc, +"processing device status change event could not identify device for handle(0x%04x)\n" , + dev_handle); goto out; + }if (hide) tgtdev->is_hidden = hide;if (tgtdev->starget && tgtdev->starget->hostdata) {
@@ -2906,13 +2933,13 @@ static void mpi3mr_energypackchg_evt_th(struct mpi3mr_ioc *mrioc,u16 shutdown_timeout =le16_to_cpu (evtdata->shutdown_timeout);if (shutdown_timeout <=0 ) { -ioc_warn (mrioc, +dprint_event_th (mrioc,"%s :Invalid Shutdown Timeout received = %d\n" , __func__, shutdown_timeout);return ; } -ioc_info (mrioc, +dprint_event_th (mrioc,"%s :Previous Shutdown Timeout Value = %d New Shutdown Timeout Value = %d\n" , __func__, mrioc->facts.shutdown_timeout, shutdown_timeout); mrioc->facts.shutdown_timeout = shutdown_timeout;
@@ -3017,9 +3044,11 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,struct mpi3_device_page0 *dev_pg0 = (struct mpi3_device_page0 *)event_reply->event_data;if (mpi3mr_create_tgtdev (mrioc, dev_pg0)) -ioc_err (mrioc, -"%s :Failed to add device in the device add event\n" , - __func__); +dprint_event_th (mrioc, +"failed to process device added event for handle(0x%04x),\n" +"perst_id(%d) in the event top half handler\n" , +le16_to_cpu (dev_pg0->dev_handle), +le16_to_cpu (dev_pg0->persistent_id));else process_evt_bh =1 ;break ;
@@ -3082,11 +3111,15 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,break ; }if (process_evt_bh || ack_req) { +dprint_event_th (mrioc, +"scheduling bottom half handler for event(0x%02x),ack_required=%d\n" , + evt_type, ack_req); sz = event_reply->event_data_length *4 ; fwevt =mpi3mr_alloc_fwevt (sz);if (!fwevt) { -ioc_info (mrioc,"%s :failure at %s:%d/%s()!\n" , - __func__, __FILE__, __LINE__, __func__); +dprint_event_th (mrioc, +"failed to schedule bottom half handler for\n" +"event(0x%02x), ack_required=%d\n" , evt_type, ack_req);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 309/1756 scsi: mpi3mr: Fix device loss during enclosure reboot due to zero link speed
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit d6c8e8b7c98c3cb326515ef4bc5c57e16ac5ae4e ]
During enclosure reboot or expander reset, firmware may report a link speed of 0 in "Device Add" events while the link is still coming up. The driver drops such devices, leaving them missing even after the link recovers.
Fix this by treating link speed 0 as 1.5 Gbps during device addition so the device is exposed to the OS. The actual link speed will be updated later when link-up events arrive.
Stable-dep-of: 77554f01187d ("scsi: mpi3mr: Fix out-of-bounds read of event data")
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 8 ++++---- drivers/scsi/mpi3mr/mpi3mr_transport.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +4 -4
@@ -2049,8 +2049,8 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,if (!fwevt->process_evt) goto evt_ack; -dprint_event_bh (mrioc,"processing event(0x%02x) in the bottom half handler\n" , - fwevt->event_id); +dprint_event_bh (mrioc,"processing event(0x%02x) -(0x%08x) in the bottom half handler\n" , + fwevt->event_id, fwevt->evt_ctx);switch (fwevt->event_id) {case MPI3_EVENT_DEVICE_ADDED :
@@ -3112,8 +3112,8 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, }if (process_evt_bh || ack_req) {dprint_event_th (mrioc, -"scheduling bottom half handler for event(0x%02x),ack_required=%d\n" , - evt_type, ack_req); +"scheduling bottom half handler for event(0x%02x) - (0x%08x), ack_required=%d\n" , + evt_type,le32_to_cpu (event_reply->event_context), ack_req); sz = event_reply->event_data_length *4 ; fwevt =mpi3mr_alloc_fwevt (sz);if (!fwevt) {
drivers/scsi/mpi3mr/mpi3mr_transport.c +9 -2
@@ -413,9 +413,11 @@ static void mpi3mr_remove_device_by_sas_address(struct mpi3mr_ioc *mrioc, sas_address, hba_port);if (tgtdev) {if (!list_empty (&tgtdev->list)) { -list_del_init (&tgtdev->list); was_on_tgtdev_list =1 ; -mpi3mr_tgtdev_put (tgtdev); +if (tgtdev->state ==MPI3MR_DEV_REMOVE_HS_STARTED ) { +list_del_init (&tgtdev->list); +mpi3mr_tgtdev_put (tgtdev); + } } }spin_unlock_irqrestore (&mrioc->tgtdev_lock, flags);
@@ -2087,6 +2089,8 @@ int mpi3mr_expander_add(struct mpi3mr_ioc *mrioc, u16 handle) link_rate = (expander_pg1.negotiated_link_rate &MPI3_SAS_NEG_LINK_RATE_LOGICAL_MASK ) >>MPI3_SAS_NEG_LINK_RATE_LOGICAL_SHIFT ; +if (link_rate <MPI3_SAS_NEG_LINK_RATE_1_5 ) + link_rate =MPI3_SAS_NEG_LINK_RATE_1_5 ;mpi3mr_update_links (mrioc, sas_address_parent, handle, i, link_rate, hba_port); }
@@ -2396,6 +2400,9 @@ int mpi3mr_report_tgtdev_to_sas_transport(struct mpi3mr_ioc *mrioc, link_rate =mpi3mr_get_sas_negotiated_logical_linkrate (mrioc, tgtdev); +if (link_rate <MPI3_SAS_NEG_LINK_RATE_1_5 ) + link_rate =MPI3_SAS_NEG_LINK_RATE_1_5 ; +mpi3mr_update_links (mrioc, sas_address_parent, tgtdev->dev_handle, parent_phy_number, link_rate, hba_port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 310/1756 scsi: mpi3mr: Rename log data save helper to reflect threaded/BH context
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
[ Upstream commit d0d19250ed81907eac707be8221eb31e5b96b647 ]
Log data events can be processed from BH and threaded contexts. Rename the save helper to document its intended usage and improve readability of the event handling flow.
Stable-dep-of: 77554f01187d ("scsi: mpi3mr: Fix out-of-bounds read of event data")
--- drivers/scsi/mpi3mr/mpi3mr.h | 2 +- drivers/scsi/mpi3mr/mpi3mr_app.c | 4 ++-- drivers/scsi/mpi3mr/mpi3mr_os.c | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +1 -1
@@ -1488,7 +1488,7 @@ void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc, struct mpi3mr_drv_cmd *drv_cmd);int mpi3mr_pel_get_seqnum_post (struct mpi3mr_ioc *mrioc,struct mpi3mr_drv_cmd *drv_cmd); -void mpi3mr_app_save_logdata (struct mpi3mr_ioc *mrioc,char *event_data, +void mpi3mr_app_save_logdata_th (struct mpi3mr_ioc *mrioc,char *event_data,u16 event_data_size);struct mpi3mr_enclosure_node *mpi3mr_enclosure_find_by_handle (struct mpi3mr_ioc *mrioc,u16 handle);
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -2
@@ -2847,7 +2847,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) }/** -* mpi3mr_app_save_logdata - Save Log Data events +* mpi3mr_app_save_logdata_th - Save Log Data events * @mrioc: Adapter instance reference * @event_data: event data associated with log data event * @event_data_size: event data size to copy
@@ -2859,7 +2859,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)* * Return:Nothing */ -void mpi3mr_app_save_logdata (struct mpi3mr_ioc *mrioc,char *event_data, +void mpi3mr_app_save_logdata_th (struct mpi3mr_ioc *mrioc,char *event_data,u16 event_data_size) {u32 index = mrioc->logdata_buf_idx;
drivers/scsi/mpi3mr/mpi3mr_os.c +6 -1
@@ -1954,7 +1954,7 @@ static void mpi3mr_pcietopochg_evt_bh(struct mpi3mr_ioc *mrioc,static void mpi3mr_logdata_evt_bh (struct mpi3mr_ioc *mrioc,struct mpi3mr_fwevt *fwevt) { -mpi3mr_app_save_logdata (mrioc, fwevt->event_data, +mpi3mr_app_save_logdata_th (mrioc, fwevt->event_data, fwevt->event_data_size); }
@@ -3084,6 +3084,11 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, }case MPI3_EVENT_DEVICE_INFO_CHANGED :case MPI3_EVENT_LOG_DATA : + + sz = event_reply->event_data_length *4 ; +mpi3mr_app_save_logdata_th (mrioc, + (char *)event_reply->event_data, sz); +break ;case MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE :case MPI3_EVENT_ENCL_DEVICE_ADDED : {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 311/1756 scsi: mpi3mr: Fix out-of-bounds read of event data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 77554f01187d91c20f04d2a8e28270943ed64cca ]
The event data length from the reply is used as is, both when caching log data and when sizing the buffer handed to the bottom half. A length larger than the frame makes both of them read past the end of it.
Clamp the length to what the frame can hold.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +13 -3
@@ -3024,7 +3024,7 @@ void mpi3mr_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc)void mpi3mr_os_handle_events (struct mpi3mr_ioc *mrioc,struct mpi3_event_notification_reply *event_reply) { -u16 evt_type, sz; +u16 evt_type, sz, avail_reply_room;struct mpi3mr_fwevt *fwevt =NULL ;bool ack_req =0 , process_evt_bh =0 ;
@@ -3085,7 +3085,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,case MPI3_EVENT_DEVICE_INFO_CHANGED :case MPI3_EVENT_LOG_DATA : - sz = event_reply->event_data_length *4 ; +if (mrioc->reply_sz > offsetof(struct mpi3_event_notification_reply , event_data)) + avail_reply_room = mrioc->reply_sz - + offsetof(struct mpi3_event_notification_reply , event_data); +else + avail_reply_room =0 ; + sz =min_t (u16, event_reply->event_data_length *4 , avail_reply_room);mpi3mr_app_save_logdata_th (mrioc, (char *)event_reply->event_data, sz);break ;
@@ -3119,7 +3124,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,dprint_event_th (mrioc,"scheduling bottom half handler for event(0x%02x) - (0x%08x), ack_required=%d\n" , evt_type,le32_to_cpu (event_reply->event_context), ack_req); - sz = event_reply->event_data_length *4 ; +if (mrioc->reply_sz > offsetof(struct mpi3_event_notification_reply , event_data)) + avail_reply_room = mrioc->reply_sz - + offsetof(struct mpi3_event_notification_reply , event_data); +else + avail_reply_room =0 ; + sz =min_t (u16, event_reply->event_data_length *4 , avail_reply_room); fwevt =mpi3mr_alloc_fwevt (sz);if (!fwevt) { dprint_event_th(mrioc,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 312/1756 scsi: mpi3mr: Fix out-of-bounds phy array access on link change
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit f67caaa2521a3c8f931d1e679d831ba5ca654794 ]
The phy number that comes with a link change is used to index the node's phy array without being compared against the number of phys allocated for that node.
Check it first.
--- drivers/scsi/mpi3mr/mpi3mr_transport.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_transport.c +7 -0
@@ -1091,6 +1091,13 @@ void mpi3mr_update_links(struct mpi3mr_ioc *mrioc,return ; } +if (phy_number >= mr_sas_node->num_phys) { +spin_unlock_irqrestore (&mrioc->sas_node_lock, flags); +ioc_err (mrioc,"%s: phy_number(%d) >= num_phys(%d)\n" , + __func__, phy_number, mr_sas_node->num_phys); +return ; + } + mr_sas_phy = &mr_sas_node->phy[phy_number]; mr_sas_phy->attached_handle = handle;spin_unlock_irqrestore (&mrioc->sas_node_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 313/1756 scsi: mpi3mr: Fix buffer overflow in the BSG target device map
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 203b3072e7aa10d98b3f2b766693ea925cfc571d ]
The size of the target device map buffer is held in a u16 while the number of devices it is derived from is not bounded to fit. With enough devices the size wraps, a short buffer is allocated, and the loop that fills it writes past the end.
Do the calculation in size_t.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +4 -3
@@ -1382,7 +1382,8 @@ static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc,static long mpi3mr_get_all_tgt_info (struct mpi3mr_ioc *mrioc,struct bsg_job *job) { -u16 num_devices =0 , i =0 , size; +u16 num_devices =0 , i =0 ; +size_t size;unsigned long flags;struct mpi3mr_tgt_dev *tgtdev;struct mpi3mr_device_map_info *devmap_info =NULL ;
@@ -1408,8 +1409,8 @@ static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc,return 0 ; } - kern_entrylen = num_devices *sizeof (*devmap_info); - size =sizeof (u64) + kern_entrylen; + kern_entrylen = (uint32_t )num_devices *sizeof (*devmap_info); + size =sizeof (u64) + (size_t )kern_entrylen; alltgt_info =kzalloc (size,GFP_KERNEL );if (!alltgt_info)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 314/1756 scsi: mpi3mr: Fix out-of-bounds read in PCIe topology change events
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 7d572b4dc4ed0494e67097d4b7368666655f5c99 ]
The number of entries in a PCIe topology change event is used to walk the entry array without being compared against the amount of event data that was received.
Bound the entry count to the received event data before use.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +19 -3
@@ -2667,12 +2667,28 @@ static void mpi3mr_pcietopochg_evt_th(struct mpi3mr_ioc *mrioc,struct mpi3_event_data_pcie_topology_change_list *topo_evt = (struct mpi3_event_data_pcie_topology_change_list *)event_reply->event_data;int i; -u16 handle; -u8 reason_code; +u16 handle, avail_len; +u8 reason_code, max_entries, num_entries;struct mpi3mr_tgt_dev *tgtdev =NULL ;struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data =NULL ; -for (i =0 ; i < topo_evt->num_entries; i++) { + avail_len = event_reply->event_data_length *4 ; +if (avail_len < offsetof(struct mpi3_event_data_pcie_topology_change_list , port_entry)) { +ioc_err (mrioc,"PCIe topology event: event data too small (%u bytes)\n" , + avail_len); +return ; + } + max_entries = (avail_len - + offsetof(struct mpi3_event_data_pcie_topology_change_list , port_entry)) / +sizeof (struct mpi3_event_pcie_topo_port_entry ); + num_entries = topo_evt->num_entries; +if (num_entries > max_entries) { +ioc_err (mrioc,"PCIe topology event: num_entries(%d) exceeds max(%d)\n" , + num_entries, max_entries); +return ; + } + +for (i =0 ; i < num_entries; i++) { handle =le16_to_cpu (topo_evt->port_entry[i].attached_dev_handle);if (!handle)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 315/1756 scsi: mpi3mr: zero out diagnostic buffer status memory
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 052aea807cfbcefaf5b6ed8202f65da1fc65f4a0 ]
Memory allocated for the BSG diagnostic buffer status is not zeroed before it is copied back to user space. Several fields in this structure are reserved and never written by the driver. Use kzalloc() instead of kmalloc() to zero out the allocated memory.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +1 -1
@@ -1160,7 +1160,7 @@ static long mpi3mr_bsg_query_hdb(struct mpi3mr_ioc *mrioc, length = (sizeof (*hbd_status) + ((MPI3MR_MAX_NUM_HDB -1 ) *sizeof (*hbd_status_entry))); - hbd_status =kmalloc (length,GFP_KERNEL ); + hbd_status =kzalloc (length,GFP_KERNEL );if (!hbd_status)return -ENOMEM ; hbd_status_entry = &hbd_status->entry[0 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 316/1756 scsi: mpi3mr: Fix use-after-free of the firmware event workqueue
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit c94c746e6c80439a4a9a0e1e20f2dae62a4d57ef ]
The enqueue path reads the workqueue pointer before taking the event lock, while the remove path clears that pointer and destroys the workqueue while holding it. The enqueue can therefore reach queue_work() after the workqueue is gone.
Move the check inside the lock.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +4 -3
@@ -233,10 +233,11 @@ static void mpi3mr_fwevt_add_to_list(struct mpi3mr_ioc *mrioc, {unsigned long flags; -if (!mrioc->fwevt_worker_thread) -return ; -spin_lock_irqsave (&mrioc->fwevt_lock, flags); +if (!mrioc->fwevt_worker_thread) { +spin_unlock_irqrestore (&mrioc->fwevt_lock, flags); +return ; + }/* get fwevt reference count while adding it to fwevt_list */ mpi3mr_fwevt_get (fwevt);INIT_LIST_HEAD (&fwevt->list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 317/1756 scsi: mpi3mr: Fix NULL pointer dereference on PCI error recovery
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 2ba1d12b2629827fdb1116eb3c9f8566911f2034 ]
On a frozen PCI channel the driver unmaps the register window and frees the interrupts, but leaves the firmware event workqueue running. An event handler that is already in flight can still reach the register window after it has been unmapped.
Stop event processing and drain the queue first, and start it again when the channel resumes.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +5 -3
@@ -2034,9 +2034,11 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,mpi3mr_fwevt_del_from_list (mrioc, fwevt); mrioc->current_event = fwevt; -if (mrioc->stop_drv_processing) { -dprint_event_bh (mrioc,"ignoring event(0x%02x) in the bottom half handler\n" -"due to stop_drv_processing\n" , fwevt->event_id); +if (mrioc->stop_drv_processing || mrioc->pci_err_recovery) { +dprint_event_bh (mrioc, +"ignoring event(0x%02x) in the bottom half handler\n" +"due to stop_drv_processing or pci_err_recovery\n" , + fwevt->event_id); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 318/1756 iio: accel: kionix-kx022a: Fix IPOL macro name
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 4a4b0d75622f7d911c96045b328fe2e88be05072 ]
The "interrupt polarity high"-macro for KX022A variant is defined as:
"#define KX022A_MASK_IPOL KX022A_MASK_IPOL1"
However, the KX022A_MASK_IPOL1 is not defined anywhere, so actually using the KX022A_IPOL_HIGH would produce a compile error.
Fix the define by using correct mask.
--- drivers/iio/accel/kionix-kx022a.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kionix-kx022a.h +1 -1
@@ -64,7 +64,7 @@#define KX022A_MASK_IEN BIT(5)#define KX022A_MASK_IPOL BIT(4)#define KX022A_IPOL_LOW 0 -#define KX022A_IPOL_HIGH KX022A_MASK_IPOL1 +#define KX022A_IPOL_HIGH KX022A_MASK_IPOL#define KX022A_MASK_ITYP BIT(3)#define KX022A_ITYP_PULSE KX022A_MASK_ITYP#define KX022A_ITYP_LEVEL 0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 319/1756 iio: imu: adis16400: Check return value of spi_setup()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
[ Upstream commit a7c07602e00596a45de8a4a700af96392953ed38 ]
In adis16400_initial_setup(), the return value of spi_setup() was ignored. If SPI configuration fails, the driver would proceed with the initialization anyway, leading to undefined behavior or silent failures during device setup.
Check the return value of spi_setup() and return the error code immediately if it fails.
--- drivers/iio/imu/adis16400.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16400.c +4 -1
@@ -433,7 +433,10 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)else st->adis.spi->max_speed_hz =ADIS16400_SPI_FAST ; st->adis.spi->mode =SPI_MODE_3 ; -spi_setup (st->adis.spi); + + ret =spi_setup (st->adis.spi); +if (ret) +return ret; ret =__adis_initial_startup (&st->adis);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 320/1756 efi/libstub: Fix efi_set_event_at() parameter documentation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit c12a3a4b35e47fd511fbd550d3637318be41c4eb ]
efi_set_event_at() documents ids although its array index argument is named idx. This produces missing and excess parameter warnings.
Match the argument name and fix the adjacent spelling of array.
--- drivers/firmware/efi/libstub/efistub.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/efi/libstub/efistub.h +2 -2
@@ -220,8 +220,8 @@ typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *);* efi_set_event_at() - add event to events array * * @events: array of UEFI events -* @ids: index where to put the event in the array -* @event: event to add to the aray +* @idx: index where to put the event in the array +* @event: event to add to the array * * boottime->wait_for_event() takes an array of events as input. * Provide a helper to set it up correctly for mixed mode.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/1756 kernfs: fix up the unlocked attribute reads on the creation paths
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 81bdc85b4c086502f4446a58eb5d25f29bb5e9f7 ]
Two creation paths read a live node's attributes without holding kernfs_iattr_rwsem, which kernfs_iop_setattr() takes for writing. They need different fixes.
kernfs_create_link() copies the target's ia_uid and then its ia_gid into the new link. A chown of the target between the two reads leaves the link with the old uid and the new gid, an owner the target never had. Read both under the rwsem.
kernfs_new_node() reads the parent's mode and ia_gid for S_ISGID inheritance. Either value is fine there: the node does not exist yet, so nothing orders a racing chmod or chown against the creation. Taking the rwsem would only pick between two answers that are both right. Mark the reads with READ_ONCE() instead.
The pointer that leads to them is already fine: __kernfs_iattrs() publishes kernfs_node::iattr with try_cmpxchg(), and both sides read it with READ_ONCE(), like the rest of fs/kernfs.
The Fixes tag is for the symlink half. kernfs_create_link() has read the pair unlocked since it started copying the target's owner; only the name of the lock its writer takes has changed. The READ_ONCE() markings are not a fix.
--- fs/kernfs/dir.c | 12 +++++++++--- fs/kernfs/symlink.c | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-)
fs/kernfs/dir.c +9 -3
@@ -685,13 +685,19 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, {struct kernfs_node *kn; -if (parent->mode &S_ISGID ) { +/* +* The mode and the gid below are read unlocked on purpose: they feed +* a node that does not exist yet, so nothing orders a racing chmod or +* chown against this creation. +*/ +if (READ_ONCE (parent->mode) &S_ISGID ) {/* this code block imitates inode_init_owner() for * kernfs */ +struct kernfs_iattrs *attrs =READ_ONCE (parent->iattr); -if (parent->iattr) - gid = parent->iattr->ia_gid; +if (attrs) + gid =READ_ONCE (attrs->ia_gid);if (flags &KERNFS_DIR ) mode |=S_ISGID ;
fs/kernfs/symlink.c +14 -3
@@ -31,9 +31,20 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,kuid_t uid =GLOBAL_ROOT_UID ;kgid_t gid =GLOBAL_ROOT_GID ; -if (target->iattr) { - uid = target->iattr->ia_uid; - gid = target->iattr->ia_gid; +/* +* A symlink takes its owner from its target, so both fields have to +* come from the same moment: read them under kernfs_iattr_rwsem, or +* a chown of the target racing this could leave the link with the +* old uid and the new gid. The section ends before kernfs_add_one() +* takes kernfs_rwsem. +*/ + scoped_guard(rwsem_read, &kernfs_root(target)->kernfs_iattr_rwsem) { +struct kernfs_iattrs *attrs =READ_ONCE (target->iattr); + +if (attrs) { + uid = attrs->ia_uid; + gid = attrs->ia_gid; + } } kn =kernfs_new_node (parent, name,S_IFLNK |0777 , uid, gid,KERNFS_LINK );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/1756 PCI: xgene: Use managed clock for PCIe controller
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit b9022584ebbae81f7bbe4a61bd1df0d0a95e1a99 ]
xgene_pcie_init_port() obtains and enables the controller clock manually. When xgene_pcie_setup() or pci_host_probe() fails, probe returns without disabling, unpreparing, or releasing the clock. A failed enable also leaves the clk_get() reference unreleased.
Use devm_clk_get_enabled() so the clock is unwound automatically on probe failure and device removal.
--- drivers/pci/controller/pci-xgene.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/pci/controller/pci-xgene.c +2 -9
@@ -322,18 +322,11 @@ static void xgene_pcie_linkup(struct xgene_pcie *port,static int xgene_pcie_init_port (struct xgene_pcie *port) {struct device *dev = port->dev; -int rc; - port->clk =clk_get (dev,NULL ); + port->clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (port->clk)) {dev_err (dev,"clock not available\n" ); -return -ENODEV ; - } - - rc =clk_prepare_enable (port->clk); -if (rc) { -dev_err (dev,"clock enable failed\n" ); -return rc; +return PTR_ERR (port->clk); }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 323/1756 RDMA/hns: Limit gmv_entry_num to avoid memory waste
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit bb464eeadd301c3a53e9f92a2a472b73c42b74c4 ]
The GMV entry is a HW object corresponding to a GID. Since gid_table_len is already limited to a maximum of 256, there is no need to allocate memory for those extra GMV entries as they will never be touched.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -2
@@ -2165,8 +2165,7 @@ static void apply_func_caps(struct hns_roce_dev *hr_dev) caps->gmv_bt_num * (HNS_HW_PAGE_SIZE / caps->gmv_entry_sz)); - caps->gmv_entry_num = caps->gmv_bt_num * (HNS_HW_PAGE_SIZE / - caps->gmv_entry_sz); + caps->gmv_entry_num = caps->gid_table_len[0 ]; }else {u32 func_num =max_t (u32,1 , hr_dev->func_num);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 324/1756 RDMA/hns: Fix GID capacity loss in 64K system
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 95761b8736c938759032e8d4eb42074d39d13007 ]
Our HW always handles GMV BT pages with a fixed 4K size, but the driver calculates the needed GMV BT pages number with PAGE_SIZE, which is 64K in 64K system. Only the first 4K (GMV index 0-127) can be reached by HW, causing GID capacity loss and memory waste.
Split a single 64K BT page into multiple 4K pages and register them to HW per 4K block so that HW can correctly reach all GMV entries.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 37 +++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +29 -8
@@ -4136,18 +4136,39 @@ static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type,static int config_gmv_ba_to_hw (struct hns_roce_dev *hr_dev,unsigned long obj,dma_addr_t base_addr) { +u32 obj_num_per_bt =HNS_HW_PAGE_SIZE / hr_dev->caps.gmv_entry_sz; +u32 chunk_size =1 << (hr_dev->caps.gmv_buf_pg_sz +PAGE_SHIFT ); +u32 bt_num_per_chunk = chunk_size /HNS_HW_PAGE_SIZE ; +u32 first = obj / obj_num_per_bt; +u32 last =min (first + bt_num_per_chunk, hr_dev->caps.gmv_bt_num);struct hns_roce_cmq_desc desc; -struct hns_roce_cmq_req *req = (struct hns_roce_cmq_req *)desc.data; -u32 idx = obj / (HNS_HW_PAGE_SIZE / hr_dev->caps.gmv_entry_sz); -u64 addr =to_hr_hw_page_addr (base_addr); +struct hns_roce_cmq_req *req; +u64 addr; +int ret; +u32 i; -hns_roce_cmq_setup_basic_desc (&desc,HNS_ROCE_OPC_CFG_GMV_BT , false); +/* The GMV BT entry of hardware covers a fixed 4K region, so a buffer +* chunk larger than 4K must be registered to hardware with one BT +* entry per 4K block, otherwise the GMV entries beyond the first +* 4K of the chunk are unreachable. +*/ +for (i = first; i < last; i++) { +hns_roce_cmq_setup_basic_desc (&desc,HNS_ROCE_OPC_CFG_GMV_BT , + false); + req = (struct hns_roce_cmq_req *)desc.data; -hr_reg_write (req,CFG_GMV_BT_BA_L ,lower_32_bits (addr)); -hr_reg_write (req,CFG_GMV_BT_BA_H ,upper_32_bits (addr)); -hr_reg_write (req,CFG_GMV_BT_IDX , idx); + addr =to_hr_hw_page_addr (base_addr + + (u64)(i - first) *HNS_HW_PAGE_SIZE ); +hr_reg_write (req,CFG_GMV_BT_BA_L ,lower_32_bits (addr)); +hr_reg_write (req,CFG_GMV_BT_BA_H ,upper_32_bits (addr)); +hr_reg_write (req,CFG_GMV_BT_IDX , i); -return hns_roce_cmq_send (hr_dev, &desc,1 ); + ret =hns_roce_cmq_send (hr_dev, &desc,1 ); +if (ret) +return ret; + } + +return 0 ; } static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 325/1756 usb: image: microtek: stop SG processing after transfer errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Diego Fernando Mancera Gomez <[email protected]>
[ Upstream commit d937ca39cc44a01ce64865dd25b1e205a05ae3a0 ]
When an SG URB completes with an error, mts_do_sg() calls mts_transfer_cleanup(), which completes the SCSI command through scsi_done(). However, the callback continues advancing the scatterlist and may submit another URB for a command that has already been completed.
Return immediately after the cleanup so that no further processing is performed on the completed command.
--- drivers/usb/image/microtek.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/image/microtek.c +1 -0
@@ -495,6 +495,7 @@ static void mts_do_sg (struct urb* transfer)if (unlikely (status)) {set_host_byte (context->srb, (status == -ENOENT ?DID_ABORT :DID_ERROR ));mts_transfer_cleanup (transfer); +return ; } context->curr_sg =sg_next (context->curr_sg);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/1756 USB: usbmon: fix null-ptr-deref in mon_bus_remove() when mon_bus_init() fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangong.Han <[email protected]>
[ Upstream commit 0c6cae0f56239e3274b30dbe5b362cd297ccacc7 ]
When mon_bus_init() fails to allocate the mon_bus struct, it returns without setting ubus->mon_bus, so mbus->mon_bus remains NULL. mon_bus_add() intentionally ignores this failure because the USB core does not require monitoring to be established for normal operation. However, when the HCD is later removed, usb_remove_hcd() fires the USB_BUS_REMOVE notifier which calls mon_bus_remove(), it dereferences ubus->mon_bus without checking for NULL, causing a null-ptr deference.
Fix this by adding a NULL check for mbus at the top of mon_bus_remove(). If mon_bus_init() failed, ubus->mon_bus is NULL, meaning the bus was never tracked by the monitor, so there is nothing to clean up and returning early is correct.
--- drivers/usb/mon/mon_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/mon/mon_main.c +3 -0
@@ -199,6 +199,9 @@ static void mon_bus_remove(struct usb_bus *ubus) {struct mon_bus *mbus = ubus->mon_bus; +if (mbus ==NULL ) +return ; +mutex_lock (&mon_lock);list_del (&mbus->bus_link);if (mbus->text_inited)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 327/1756 USB: pci-quirks: Release EHCI device reference
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit e93731c29f749d5b2495a67109d1f0804ab3b89d ]
for_each_pci_dev() holds a reference to the current device. The Intel EHCI lookup breaks as soon as it finds a match, so the iterator does not get a chance to drop that reference on its next iteration.
Release the reference before leaving the loop.
--- drivers/usb/host/pci-quirks.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/pci-quirks.c +1 -0
@@ -1073,6 +1073,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)if (companion->class ==PCI_CLASS_SERIAL_USB_EHCI && companion->vendor ==PCI_VENDOR_ID_INTEL ) { ehci_found = true; +pci_dev_put (companion);break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 328/1756 usb-storage: alauda: do not do DMA from the stack
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit ec67dacb75ebd11fbe6d727e6f37c0ef5e3d3431 ]
alauda_check_status2(), alauda_get_redu_data(), alauda_erase_block(), alauda_read_block_raw() and alauda_write_block() build their commands in stack arrays and pass them to usb_stor_bulk_transfer_buf(). alauda_check_status2() and alauda_erase_block() also read the reply back into a stack array.
usb_stor_msg_common() sets URB_NO_TRANSFER_DMA_MAP only when the buffer is us->iobuf. Every other buffer reaches usb_hcd_map_urb_for_dma(), which has warned and returned -EAGAIN for a buffer on the stack since commit 4568136620c6 ("usb: core: Check URB setup_packet and transfer_buffer sanity"). On a host controller that uses DMA, all of these commands fail.
Use us->iobuf, as alauda_reset_media() in this driver and the other usb-storage subdrivers already do. The command is sent before the reply is read, so both can use it; sddr09_read_status() does the same.
--- drivers/usb/storage/alauda.c | 70 ++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 22 deletions(-)
drivers/usb/storage/alauda.c +48 -22
@@ -500,11 +500,14 @@ static int alauda_check_media(struct us_data *us)static int alauda_check_status2 (struct us_data *us) {int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_GET_STATUS2 , -0 ,0 ,0 ,0 ,3 ,0 ,MEDIA_PORT (us) - }; -unsigned char data[3 ]; +unsigned char *command = us->iobuf; +unsigned char *data = us->iobuf; + +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_GET_STATUS2 ; + command[6 ] =3 ; + command[8 ] =MEDIA_PORT (us); rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );
@@ -530,10 +533,15 @@ static int alauda_check_status2(struct us_data *us)static int alauda_get_redu_data (struct us_data *us,u16 pba,unsigned char *data) {int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_GET_REDU_DATA , -PBA_HI (pba),PBA_ZONE (pba),0 ,PBA_LO (pba),0 ,0 ,MEDIA_PORT (us) - }; +unsigned char *command = us->iobuf; + +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_GET_REDU_DATA ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba); + command[8 ] =MEDIA_PORT (us); rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );
@@ -702,14 +710,20 @@ static void alauda_ensure_map_for_zone(struct us_data *us, unsigned int zone)static int alauda_erase_block (struct us_data *us,u16 pba) {int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_ERASE_BLOCK ,PBA_HI (pba), -PBA_ZONE (pba),0 ,PBA_LO (pba),0x02 ,0 ,MEDIA_PORT (us) - }; -unsigned char buf[2 ]; +unsigned char *command = us->iobuf; +unsigned char *buf = us->iobuf;usb_stor_dbg (us,"Erasing PBA %d\n" , pba); +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_ERASE_BLOCK ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba); + command[6 ] =0x02 ; + command[8 ] =MEDIA_PORT (us); + rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );if (rc !=USB_STOR_XFER_GOOD )
@@ -732,13 +746,19 @@ static int alauda_read_block_raw(struct us_data *us, u16 pba, unsigned int page, unsigned int pages, unsigned char *data) { int rc; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_READ_BLOCK ,PBA_HI (pba), -PBA_ZONE (pba),0 ,PBA_LO (pba) + page, pages,0 ,MEDIA_PORT (us) - }; +unsigned char *command = us->iobuf;usb_stor_dbg (us,"pba %d page %d count %d\n" , pba, page, pages); +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_READ_BLOCK ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba) + page; + command[6 ] = pages; + command[8 ] =MEDIA_PORT (us); + rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );if (rc !=USB_STOR_XFER_GOOD )
@@ -783,13 +803,19 @@ static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data) {int rc;struct alauda_info *info = (struct alauda_info *) us->extra; -unsigned char command[] = { -ALAUDA_BULK_CMD ,ALAUDA_BULK_WRITE_BLOCK ,PBA_HI (pba), -PBA_ZONE (pba),0 ,PBA_LO (pba),32 ,0 ,MEDIA_PORT (us) - }; +unsigned char *command = us->iobuf;usb_stor_dbg (us,"pba %d\n" , pba); +memset (command,0 ,9 ); + command[0 ] =ALAUDA_BULK_CMD ; + command[1 ] =ALAUDA_BULK_WRITE_BLOCK ; + command[2 ] =PBA_HI (pba); + command[3 ] =PBA_ZONE (pba); + command[5 ] =PBA_LO (pba); + command[6 ] =32 ; + command[8 ] =MEDIA_PORT (us); + rc =usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, command,9 ,NULL );if (rc !=USB_STOR_XFER_GOOD )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 329/1756 usb-storage: alauda: check the return value of alauda_read_map()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit eb882419790c6710646904c6b25132189152cf33 ]
alauda_ensure_map_for_zone() ignores the value alauda_read_map() returns. On failure lba_to_pba[zone] and pba_to_lba[zone] are left NULL, and both callers dereference them immediately:
pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset];
alauda_read_map() returns USB_STOR_TRANSPORT_ERROR when either kcalloc() fails or an alauda_get_redu_data() transfer fails, so one failed bulk transfer is enough to reach the NULL dereference.
Return that value from alauda_ensure_map_for_zone() and check it in alauda_read_data() and alauda_write_lba().
--- drivers/usb/storage/alauda.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/usb/storage/alauda.c +11 -4
@@ -697,11 +697,13 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)* Checks to see whether we have already mapped a certain zone * If we haven't, the map is generated */ -static void alauda_ensure_map_for_zone (struct us_data *us,unsigned int zone) +static int alauda_ensure_map_for_zone (struct us_data *us,unsigned int zone) {if (MEDIA_INFO (us).lba_to_pba[zone] ==NULL ||MEDIA_INFO (us).pba_to_lba[zone] ==NULL ) -alauda_read_map (us, zone); +return alauda_read_map (us, zone); + +return 0 ; }/*
@@ -849,7 +851,9 @@ static int alauda_write_lba(struct us_data *us, u16 lba,unsigned int new_pba_offset;unsigned int zone = lba / uzonesize; -alauda_ensure_map_for_zone (us, zone); + result =alauda_ensure_map_for_zone (us, zone); +if (result !=USB_STOR_TRANSPORT_GOOD ) +return result; pba =MEDIA_INFO (us).lba_to_pba[zone][lba_offset];if (pba ==1 ) {
@@ -980,7 +984,10 @@ static int alauda_read_data(struct us_data *us, unsigned long address,unsigned int lba_offset = lba - (zone * uzonesize);unsigned int pages;u16 pba; -alauda_ensure_map_for_zone (us, zone); + + result =alauda_ensure_map_for_zone (us, zone); +if (result !=USB_STOR_TRANSPORT_GOOD ) +break ;/* Not overflowing capacity? */ if (lba >= max_lba) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 330/1756 usb-storage: alauda: fix out-of-bounds zone index
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit c4542993c071fcafe7335698bf52650dee7e3555 ]
MEDIA_INFO(us).lba_to_pba and .pba_to_lba are arrays of num_zones pointers, allocated by kcalloc() in alauda_init_media(). alauda_ensure_map_for_zone() reads lba_to_pba[zone] and pba_to_lba[zone], and when either is NULL alauda_read_map() writes a pointer back to both. Two separate errors let zone reach num_zones, one element past the end.
max_lba is capacity >> (blockshift + pageshift), which counts physical blocks, but zone is lba / uzonesize and uzonesize is 125/128 of zonesize. On a 16 MB card (alauda_card_ids id 0x73) num_zones is 1 and uzonesize is 1000, so lba 1000 to 1023 pass the bounds check and index element 1 of a one-element array.
alauda_read_data() also calls alauda_ensure_map_for_zone() before it compares lba against max_lba, so any larger lba is used as an index before the check rejects it. alauda_write_data() already checks first.
Bound lba by num_zones * uzonesize on both paths and move the read side's call below the check. alauda_transport() reports num_zones * uzonesize * blocksize for READ_CAPACITY, so the new bound is exactly the range the device advertises and no block becomes unreachable.
sd never issues an lba past the reported capacity; an SG_IO READ_10 can.
--- drivers/usb/storage/alauda.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/usb/storage/alauda.c +12 -6
@@ -949,6 +949,7 @@ static int alauda_read_data(struct us_data *us, unsigned long address,unsigned char *buffer;u16 lba, max_lba;unsigned int page, len, offset; +unsigned int num_zones;unsigned int blockshift =MEDIA_INFO (us).blockshift;unsigned int pageshift =MEDIA_INFO (us).pageshift;unsigned int blocksize =MEDIA_INFO (us).blocksize;
@@ -973,7 +974,9 @@ static int alauda_read_data(struct us_data *us, unsigned long address,/* Figure out the initial LBA and page */ lba = address >> blockshift; page = (address &MEDIA_INFO (us).blockmask); - max_lba =MEDIA_INFO (us).capacity >> (blockshift + pageshift); + num_zones =MEDIA_INFO (us).capacity >> (MEDIA_INFO (us).zoneshift + + blockshift + pageshift); + max_lba = num_zones * uzonesize; result =USB_STOR_TRANSPORT_GOOD ; offset =0 ;
@@ -985,10 +988,6 @@ static int alauda_read_data(struct us_data *us, unsigned long address,unsigned int pages;u16 pba; - result =alauda_ensure_map_for_zone (us, zone); -if (result !=USB_STOR_TRANSPORT_GOOD ) -break ; -/* Not overflowing capacity? */ if (lba >= max_lba) { usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n",
@@ -997,6 +996,10 @@ static int alauda_read_data(struct us_data *us, unsigned long address,break ; } + result =alauda_ensure_map_for_zone (us, zone); +if (result !=USB_STOR_TRANSPORT_GOOD ) +break ; +/* Find number of pages we can read in this block */ pages =min (sectors, blocksize - page); len = pages << pageshift;
@@ -1052,6 +1055,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address,unsigned int pagesize =MEDIA_INFO (us).pagesize;struct scatterlist *sg;u16 lba, max_lba; +unsigned int num_zones;int result;/*
@@ -1078,7 +1082,9 @@ static int alauda_write_data(struct us_data *us, unsigned long address,/* Figure out the initial LBA and page */ lba = address >> blockshift; page = (address &MEDIA_INFO (us).blockmask); - max_lba =MEDIA_INFO (us).capacity >> (pageshift + blockshift); + num_zones =MEDIA_INFO (us).capacity >> (MEDIA_INFO (us).zoneshift + + blockshift + pageshift); + max_lba = num_zones *MEDIA_INFO (us).uzonesize; result =USB_STOR_TRANSPORT_GOOD ; offset =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 331/1756 usb: musb: da8xx: depopulate OF children on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 4b30c89fb36924983be652bb24fc49e20390bf27 ]
da8xx_probe() creates CPPI platform devices with of_platform_populate(), but da8xx_remove() unregisters only the separately created MUSB device and the generic PHY. The OF children therefore remain registered after the glue driver is unbound.
Pair the successful population with of_platform_depopulate() during remove. Unregister the MUSB device first because it reuses the parent DT node but was not created by of_platform_populate().
--- drivers/usb/musb/da8xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/musb/da8xx.c +1 -0
@@ -590,6 +590,7 @@ static void da8xx_remove(struct platform_device *pdev)struct da8xx_glue *glue =platform_get_drvdata (pdev);platform_device_unregister (glue->musb); +of_platform_depopulate (&pdev->dev);usb_phy_generic_unregister (glue->usb_phy); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/1756 usb: musb: da8xx: depopulate OF children on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 8d70a378e702141424e27e0b8341e421f058635d ]
da8xx_probe() creates the CPPI child devices before registering the MUSB platform device. If population partially succeeds or the later MUSB registration fails, the probe path unregisters the generic PHY but leaves the OF children registered under a parent whose probe failed.
Depopulate the OF children before unregistering the PHY on both failure paths. Use one cleanup label so each resource is unwound in reverse publication order without introducing an unused label.
--- drivers/usb/musb/da8xx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/musb/da8xx.c +4 -3
@@ -560,7 +560,7 @@ static int da8xx_probe(struct platform_device *pdev) ret =of_platform_populate (pdev->dev.of_node,NULL , da8xx_auxdata_lookup, &pdev->dev);if (ret) - goto err_unregister_phy; + goto err_depopulate; pinfo = da8xx_dev_info; pinfo.parent = &pdev->dev;
@@ -575,12 +575,13 @@ static int da8xx_probe(struct platform_device *pdev) ret =PTR_ERR_OR_ZERO (glue->musb);if (ret) {dev_err (&pdev->dev,"failed to register musb device: %d\n" , ret); - goto err_unregister_phy; + goto err_depopulate; }return 0 ; -err_unregister_phy: +err_depopulate: +of_platform_depopulate (&pdev->dev);usb_phy_generic_unregister (glue->usb_phy);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/1756 dmaengine: sprd: use clk_bulk API to fix clock imbalance
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaithanya Lagisetty <[email protected]>
[ Upstream commit d09cd5e8bbc98969b5333015b45c525078ac0f6f ]
sprd_dma_enable() enabled sdev->clk and then the optional ashb_clk. If enabling ashb_clk failed, sdev->clk was left enabled: both callers (probe and resume) treat a non-zero return as "nothing was enabled" and bail out, leaking sdev->clk.
Convert the driver to the clk_bulk API. clk_bulk_prepare_enable() enables all clocks and unwinds them on failure, and clk_bulk_disable_unprepare() disables them, which fixes the imbalance and simplifies the enable/disable paths. Both clocks are fetched with devm_clk_bulk_get_optional(); the optional ashb_eb clock simply becomes a NULL entry that the bulk helpers treat as a no-op, while the mandatory enable clock is still checked explicitly.
--- drivers/dma/sprd-dma.c | 45 ++++++++++++------------------------------ 1 file changed, 13 insertions(+), 32 deletions(-)
drivers/dma/sprd-dma.c +13 -32
@@ -208,8 +208,7 @@ struct sprd_dma_chn {struct sprd_dma_dev {struct dma_device dma_dev;void __iomem *glb_base; -struct clk *clk; -struct clk *ashb_clk; +struct clk_bulk_data clks[2 ];int irq;u32 total_chns; struct sprd_dma_chn channels[] __counted_by(total_chns);
@@ -260,31 +259,12 @@ static void sprd_dma_chn_update(struct sprd_dma_chn *schan, u32 reg,static int sprd_dma_enable (struct sprd_dma_dev *sdev) { -int ret; - - ret =clk_prepare_enable (sdev->clk); -if (ret) -return ret; - -/* -* The ashb_clk is optional and only for AGCP DMA controller, so we -* need add one condition to check if the ashb_clk need enable. -*/ -if (!IS_ERR (sdev->ashb_clk)) - ret =clk_prepare_enable (sdev->ashb_clk); - -return ret; +return clk_bulk_prepare_enable (ARRAY_SIZE (sdev->clks), sdev->clks); }static void sprd_dma_disable (struct sprd_dma_dev *sdev) { -clk_disable_unprepare (sdev->clk); - -/* -* Need to check if we need disable the optional ashb_clk for AGCP DMA. -*/ -if (!IS_ERR (sdev->ashb_clk)) -clk_disable_unprepare (sdev->ashb_clk); +clk_bulk_disable_unprepare (ARRAY_SIZE (sdev->clks), sdev->clks); }static void sprd_dma_set_uid (struct sprd_dma_chn *schan)
@@ -1140,16 +1120,17 @@ static int sprd_dma_probe(struct platform_device *pdev)if (!sdev)return -ENOMEM ; - sdev->clk =devm_clk_get (&pdev->dev,"enable" ); -if (IS_ERR (sdev->clk)) { -dev_err (&pdev->dev,"get enable clock failed\n" ); -return PTR_ERR (sdev->clk); - } +/* The ashb_eb clock is optional and only present for AGCP DMA */ + sdev->clks[0 ].id ="enable" ; + sdev->clks[1 ].id ="ashb_eb" ; + ret =devm_clk_bulk_get_optional (&pdev->dev,ARRAY_SIZE (sdev->clks), + sdev->clks); +if (ret) +return dev_err_probe (&pdev->dev, ret,"get clocks failed\n" ); -/* ashb clock is optional for AGCP DMA */ - sdev->ashb_clk =devm_clk_get (&pdev->dev,"ashb_eb" ); -if (IS_ERR (sdev->ashb_clk)) -dev_warn (&pdev->dev,"no optional ashb eb clock\n" ); +if (!sdev->clks[0 ].clk) +return dev_err_probe (&pdev->dev, -ENOENT , +"get enable clock failed\n" );/* * We have three DMA controllers: AP DMA, AON DMA and AGCP DMA. For AGCP
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/1756 firmware: arm_scmi: Protect xfer->async_done with xfer->lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roland Dreier <[email protected]>
[ Upstream commit 49fc5bc04eec2b7687d49ccceb7adf6ace640a3b ]
Asynchronous SCMI commands are completed by a delayed response. The RX path signals the response with complete(xfer->async_done). Unlike xfer->done, xfer->async_done is a pointer to a completion owned by whoever is waiting for the delayed response, and it stays valid only for as long as that waiter is still waiting. In do_xfer_with_response() it is a DECLARE_COMPLETION_ONSTACK() in the caller's stack frame.
Nothing serialises the RX path against a waiter that gives up on a timeout. scmi_msg_response_validate() does read xfer->async_done under xfer->lock, and documents that as a requirement, but the lock is dropped again before scmi_handle_response() dereferences the pointer, and neither the arming nor the disarming side takes it at all. So a delayed response arriving just as the wait times out can be signalled on a completion that is already gone:
waiter RX path (IRQ context)
------ ---------------------
do_xfer_with_response():
xfer->async_done = &async_response
do_xfer(xfer)
wait_for_completion_timeout(xfer->async_done, tmo)
/* returns 0, gives up */
/* response receive interrupt */
scmi_handle_response():
scmi_xfer_command_acquire()
lock xfer->lock
validate: async_done != NULL
unlock xfer->lock
xfer->async_done = NULL
return -ETIMEDOUT
/* async_response goes out of scope */
complete(xfer->async_done)That last complete() has two possible bad outcomes: it either dereferences the NULL just stored by the waiter or - if that store is not yet visible on the RX CPU - it takes a lock and writes to a stack frame that the waiter may already have returned from.
Fix this by making xfer->lock cover xfer->async_done end-to-end. Add helpers to arm and disarm it under the lock, use them on both the regular and the raw paths, and have the RX path read and signal the completion under that same lock. A waiter that is timing out then either completes its disarm before the RX path looks, in which case the delayed response is dropped, or blocks in the disarm until the RX path is done with the completion, in which case the completion is still alive.
Log the dropped case, so every path where a delayed response that was matched to a pending xfer and then discarded produces an error. (This is the same treatment scmi_msg_response_validate() already gives a delayed response that arrives after the waiter has disarmed the xfer)
--- drivers/firmware/arm_scmi/common.h | 22 ++++++++++++++++ drivers/firmware/arm_scmi/driver.c | 37 +++++++++++++++++++++++---- drivers/firmware/arm_scmi/protocols.h | 9 ++++--- drivers/firmware/arm_scmi/raw_mode.c | 4 +-- 4 files changed, 62 insertions(+), 10 deletions(-)
drivers/firmware/arm_scmi/common.h +22 -0
@@ -266,6 +266,28 @@ static inline bool is_polling_enabled(struct scmi_chan_info *cinfo,is_transport_polling_capable (desc); } +/** +* scmi_xfer_async_response_arm - Arm the delayed response completion +* +* @xfer: A reference to the xfer to arm +* @async_done: The completion to signal upon reception of a delayed response, +* or NULL to disarm @xfer. +*/ +static inline void scmi_xfer_async_response_arm (struct scmi_xfer *xfer, +struct completion *async_done) +{ +unsigned long flags; + +spin_lock_irqsave (&xfer->lock, flags); + xfer->async_done = async_done; +spin_unlock_irqrestore (&xfer->lock, flags); +} + +static inline void scmi_xfer_async_response_disarm (struct scmi_xfer *xfer) +{ +scmi_xfer_async_response_arm (xfer,NULL ); +} +void scmi_xfer_raw_put (const struct scmi_handle *handle,struct scmi_xfer *xfer);struct scmi_xfer *scmi_xfer_raw_get (const struct scmi_handle *handle);
drivers/firmware/arm_scmi/driver.c +32 -5
@@ -1029,6 +1029,29 @@ static inline void scmi_xfer_command_release(struct scmi_info *info,__scmi_xfer_put (&info->tx_minfo, xfer); } +/** +* scmi_xfer_async_response_complete - Signal a received delayed response +* +* @xfer: A reference to the xfer whose delayed response was received +* +* Return: True if a completion was still armed on @xfer and has been +* signalled, false if a waiter has already disarmed it due to +* timeout or other error. +*/ +static bool scmi_xfer_async_response_complete (struct scmi_xfer *xfer) +{ +unsigned long flags; +struct completion *async_done; + +spin_lock_irqsave (&xfer->lock, flags); + async_done = xfer->async_done; +if (async_done) +complete (async_done); +spin_unlock_irqrestore (&xfer->lock, flags); + +return !!async_done; +} +static inline void scmi_clear_channel (struct scmi_info *info,struct scmi_chan_info *cinfo) {
@@ -1132,8 +1155,12 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,if (xfer->hdr.type ==MSG_TYPE_DELAYED_RESP ) {scmi_clear_channel (info, cinfo); -complete (xfer->async_done); -scmi_inc_count (info->dbg,DELAYED_RESPONSE_OK ); +if (scmi_xfer_async_response_complete (xfer)) +scmi_inc_count (info->dbg,DELAYED_RESPONSE_OK ); +else +dev_err (cinfo->dev, +"Delayed Response for %d (protocol 0x%X msg 0x%X) received after waiter was disarmed, dropping\n" , + xfer->hdr.seq, xfer->hdr.protocol_id, xfer->hdr.id); }else {complete (&xfer->done);scmi_inc_count (info->dbg,RESPONSE_OK );
@@ -1472,7 +1499,7 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph,int ret, timeout =msecs_to_jiffies (SCMI_MAX_RESPONSE_TIMEOUT );DECLARE_COMPLETION_ONSTACK (async_response); - xfer->async_done = &async_response; +scmi_xfer_async_response_arm (xfer, &async_response);/* * Delayed responses should not be polled, so an async command should
@@ -1484,7 +1511,7 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph, ret =do_xfer (ph, xfer);if (!ret) { -if (!wait_for_completion_timeout (xfer->async_done, timeout)) { +if (!wait_for_completion_timeout (&async_response, timeout)) {dev_err (ph->dev,"timed out in delayed resp(caller: %pS)\n" , (void *)_RET_IP_);
@@ -1494,7 +1521,7 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph, } } - xfer->async_done =NULL ; +scmi_xfer_async_response_disarm (xfer);return ret; }
drivers/firmware/arm_scmi/protocols.h +6 -3
@@ -100,7 +100,10 @@ struct scmi_msg_hdr {* message. If request-ACK protocol is used, we can reuse the same * buffer for the rx path as we use for the tx path. * @done: command message transmit completion event -* @async_done: pointer to delayed response message received event completion +* @async_done: pointer to delayed response message received event completion, +* or NULL when no delayed response is expected. Protected by +* @lock, since the completion is owned by the waiter and can +* vanish once the wait times out. * @pending: True for xfers added to @pending_xfers hashtable * @node: An hlist_node reference used to store this xfer, alternatively, on * the free list @free_xfers or in the @pending_xfers hashtable
@@ -121,7 +124,7 @@ struct scmi_msg_hdr {* - SCMI_XFER_SENT_OK -> SCMI_XFER_DRESP_OK * (Missing synchronous response is assumed OK and ignored) * @flags: Optional flags associated to this xfer. -* @lock: A spinlock to protect state and busy fields. +* @lock: A spinlock to protect state, busy and async_done fields. * @priv: A pointer for transport private usage. */ struct scmi_xfer {
@@ -147,7 +150,7 @@ struct scmi_xfer {#define SCMI_XFER_IS_CHAN_SET (x) \ ((x)->flags & SCMI_XFER_FLAG_CHAN_SET)int flags; -/* A lock to protect state and busy fields */ +/* A lock to protect state, busy and async_done fields */ spinlock_t lock;void *priv; };
drivers/firmware/arm_scmi/raw_mode.c +2 -2
@@ -346,7 +346,7 @@ scmi_xfer_raw_waiter_get(struct scmi_raw_mode_info *raw, struct scmi_xfer *xfer,if (async) {reinit_completion (&rw->async_response); - xfer->async_done = &rw->async_response; +scmi_xfer_async_response_arm (xfer, &rw->async_response); } rw->cinfo = cinfo;
@@ -361,7 +361,7 @@ static void scmi_xfer_raw_waiter_put(struct scmi_raw_mode_info *raw, struct scmi_xfer_raw_waiter *rw) {if (rw->xfer) { - rw->xfer->async_done =NULL ; +scmi_xfer_async_response_disarm (rw->xfer); rw->xfer =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/1756 firmware: arm_scmi: Dont reuse raw xfers with async_done still armed
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roland Dreier <[email protected]>
[ Upstream commit 0543fc1443de1a0b04ec64684fb920d79e15de2f ]
In SCMI raw mode, scmi_xfer_raw_worker() releases the xfer before releasing the waiter that disarms xfer->async_done, and scmi_xfer_get() does not clear async_done when it hands out a recycled xfer. A concurrent transaction can therefore pick up the xfer while it still points at the old waiter's completion, so:
- a delayed response arriving for the new transaction can be signalled on the old waiter's completion, which may already be re-armed for yet another unrelated transaction, making that transaction's wait return early; and
- the old waiter's disarm, which still runs after the xfer has been released, clobbers the arming just installed by the new transaction, so the new waiter times out even if its delayed response arrives.
Release the waiter first, while the worker still holds a reference on the xfer, so that an xfer can never reach the free list still armed. Track whether a delayed response is expected in the waiter itself instead of peeking at xfer->async_done outside xfer->lock, and wait on the waiter's own embedded completion. (The new async flag is not strictly needed but it makes the logic easier to reason about)
Finally, harden scmi_xfer_get() to clear async_done when handing out an xfer, so that no future release-ordering change can leak a stale arming into a new transaction.
--- drivers/firmware/arm_scmi/driver.c | 1 + drivers/firmware/arm_scmi/raw_mode.c | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)
drivers/firmware/arm_scmi/driver.c +1 -0
@@ -687,6 +687,7 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle,refcount_set (&xfer->users,1 );atomic_set (&xfer->busy,SCMI_XFER_FREE ); + xfer->async_done =NULL ;spin_unlock_irqrestore (&minfo->xfer_lock, flags);return xfer;
drivers/firmware/arm_scmi/raw_mode.c +21 -4
@@ -198,6 +198,8 @@ struct scmi_raw_mode_info {* @async_response: A completion to be, optionally, used for async waits: it * will be setup by @scmi_do_xfer_raw_start, if needed, to be * pointed at by xfer->async_done. +* @async: True if @async_response was armed on @xfer, i.e. if a delayed +* response has to be waited for. * @node: A list node. */ struct scmi_xfer_raw_waiter {
@@ -205,6 +207,7 @@ struct scmi_xfer_raw_waiter {struct scmi_chan_info *cinfo;struct scmi_xfer *xfer;struct completion async_response; +bool async;struct list_head node; };
@@ -349,6 +352,7 @@ scmi_xfer_raw_waiter_get(struct scmi_raw_mode_info *raw, struct scmi_xfer *xfer,scmi_xfer_async_response_arm (xfer, &rw->async_response); } + rw->async = async; rw->cinfo = cinfo; rw->xfer = xfer; }
@@ -361,8 +365,16 @@ static void scmi_xfer_raw_waiter_put(struct scmi_raw_mode_info *raw, struct scmi_xfer_raw_waiter *rw) {if (rw->xfer) { +/* +* Disarm the delayed response before this waiter, and its +* embedded completion, can be picked up again for a new +* transaction: a delayed response received late, after the +* related wait timed out, must not signal a completion which +* has been in the meantime re-armed on a different xfer. +*/ scmi_xfer_async_response_disarm (rw->xfer); rw->xfer =NULL ; + rw->async = false; }mutex_lock (&raw->free_mtx);
@@ -478,18 +490,23 @@ static void scmi_xfer_raw_worker(struct work_struct *work) xfer->hdr.protocol_id, xfer->hdr.seq, ret);/* Wait also for an async delayed response if needed */ -if (!ret && xfer->async_done) { +if (!ret && rw->async) {unsigned long tmo =msecs_to_jiffies (SCMI_MAX_RESPONSE_TIMEOUT ); -if (!wait_for_completion_timeout (xfer->async_done, tmo)) +if (!wait_for_completion_timeout (&rw->async_response, tmo))dev_err (dev,"timed out in RAW delayed resp - HDR:%08X\n" ,pack_scmi_header (&xfer->hdr)); } -/* Release waiter and xfer */ -scmi_xfer_raw_put (raw->handle, xfer); +/* +* Release the waiter first: this disarms the delayed response +* while we still hold a reference on the xfer, so that the xfer +* cannot be recycled by a new transaction while it still points +* at this waiter's completion. +*/ scmi_xfer_raw_waiter_put (raw, rw); +scmi_xfer_raw_put (raw->handle, xfer); }while (1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/1756 usb: gadget: composite: avoid warning on aborted delayed status
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keisuke Tsukuda <[email protected]>
[ Upstream commit 048884b782b137229399b9f727b6437d9b4f1071 ]
A SET_CONFIGURATION request that disables the current configuration, or a disconnect, can abort a control transfer whose status stage was delayed by a function driver. The asynchronous function work can nevertheless finish later and call usb_composite_setup_continue() after reset_config() has cleared delayed_status.
This is an expected consequence of aborting the old control transfer, and does not require a kernel warning. Keep the diagnostic available under dynamic debug and ignore the obsolete completion as before.
--- drivers/usb/gadget/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/composite.c +1 -1
@@ -2764,7 +2764,7 @@ void usb_composite_setup_continue(struct usb_composite_dev *cdev)spin_lock_irqsave (&cdev->lock, flags);if (cdev->delayed_status ==0 ) { -WARN (cdev,"%s: Unexpected call\n" , __func__); +DBG (cdev,"%s: Ignoring obsolete call\n" , __func__); }else if (--cdev->delayed_status ==0 ) {DBG (cdev,"%s: Completing delayed status\n" , __func__);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/1756 usb: gadget: f_mass_storage: ignore class requests while inactive
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keisuke Tsukuda <[email protected]>
[ Upstream commit e84caed6e7f58d96ea2e4aaa0b947ab05faa451b ]
SET_CONFIGURATION is handled asynchronously by the mass-storage thread. A class request can arrive after the composite core selects the function but before the thread installs common->fsg, or while the function is being disabled.
fsg_setup() already rejects this state with -EOPNOTSUPP, but checking it through fsg_is_set() also emits a warning. Check the active function directly so normal requests during a configuration transition are rejected without hiding fsg_is_set() warnings from other internal paths.
--- drivers/usb/gadget/function/f_mass_storage.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_mass_storage.c +6 -1
@@ -464,7 +464,12 @@ static int fsg_setup(struct usb_function *f,u16 w_value =le16_to_cpu (ctrl->wValue);u16 w_length =le16_to_cpu (ctrl->wLength); -if (!fsg_is_set (fsg->common)) +/* +* fsg_is_set() warns when common->fsg is NULL, but that can happen +* normally while a configuration change installs or removes the active +* function. +*/ +if (!fsg->common->fsg)return -EOPNOTSUPP ; ++fsg->common->ep0_req_tag;/* Record arrival of a new request */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/1756 dmaengine: fsl_raid: zero CF descriptor pool allocations
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 26d48e9fb6997f4026dd86daecf8d2c12258f698 ]
The compound frame descriptors and embedded CDBs are allocated from the cf_desc_pool with dma_pool_alloc(), which does not zero the memory. Only cdb32, the gfm coefficients and the frame address/length fields are programmed; the dpi_dest_spec/dpi_src_spec fields in the CDBs and the rbro32 field of each frame are left uninitialized. The hardware reads the whole block (frame 0 length is sizeof(struct fsl_re_xor_cdb) or sizeof(struct fsl_re_pq_cdb)), so uninitialized heap contents are exposed to the device on each new descriptor.
Use dma_pool_zalloc() in both fsl_re_chan_alloc_desc() and fsl_re_alloc_chan_resources() so the descriptor and CDB memory is zeroed before it is handed to the RAID engine.
--- drivers/dma/fsl_raid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/fsl_raid.c +4 -4
@@ -305,8 +305,8 @@ static struct fsl_re_desc *fsl_re_chan_alloc_desc(struct fsl_re_chan *re_chan,if (!desc)return NULL ; - cf =dma_pool_alloc (re_chan->re_dev->cf_desc_pool,GFP_NOWAIT , - &paddr); + cf =dma_pool_zalloc (re_chan->re_dev->cf_desc_pool,GFP_NOWAIT , + &paddr);if (!cf) {kfree (desc);return NULL ;
@@ -594,8 +594,8 @@ static int fsl_re_alloc_chan_resources(struct dma_chan *chan)if (!desc)break ; - cf =dma_pool_alloc (re_chan->re_dev->cf_desc_pool,GFP_KERNEL , - &paddr); + cf =dma_pool_zalloc (re_chan->re_dev->cf_desc_pool,GFP_KERNEL , + &paddr);if (!cf) {kfree (desc);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/1756 dmaengine: dw-axi-dmac: Fix AXI burst length encoding
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit 0d59891c42e11c3840276d8a632dbc355d6ddc4f ]
The snps,axi-max-burst-len property describes the number of beats in an AXI burst, while the ARLEN and AWLEN fields encode that value minus one.
The driver keeps axi_rw_burst_len as the actual burst length so that dma_device.max_burst reports the correct value. However, it also programs that unencoded value directly into the hardware fields. A value of 256 therefore overflows the 8-bit fields and can cause AXI decode errors.
Subtract one only when constructing hardware descriptors, while keeping the actual value for dma_device.max_burst.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +2 -2
@@ -706,7 +706,7 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan, ctlhi =CH_CTL_H_LLI_VALID ;if (chan->chip->dw->hdata->restrict_axi_burst_len) { - burst_len = chan->chip->dw->hdata->axi_rw_burst_len; + burst_len = chan->chip->dw->hdata->axi_rw_burst_len -1 ; ctlhi |=CH_CTL_H_ARLEN_EN |CH_CTL_H_AWLEN_EN | burst_len <<CH_CTL_H_ARLEN_POS | burst_len <<CH_CTL_H_AWLEN_POS ;
@@ -977,7 +977,7 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr, reg =CH_CTL_H_LLI_VALID ;if (chan->chip->dw->hdata->restrict_axi_burst_len) { -u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len; +u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len -1 ; reg |= (CH_CTL_H_ARLEN_EN | burst_len << CH_CTL_H_ARLEN_POS |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/1756 dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit e6b49f8016ee8b642e8e495d1704342ee0b35d72 ]
axi_chan_list_dump_lli() uses the channel-wide descs_allocated count to walk the hw_desc[] array of a single transaction. If multiple transactions have allocated LLIs, the channel count can exceed the transaction-local nr_hw_descs and make the DMA error path read past the end of hw_desc[].
Use the descriptor-local nr_hw_descs count when dumping LLIs.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +1 -4
@@ -1054,10 +1054,7 @@ static void axi_chan_dump_lli(struct axi_dma_chan *chan,static void axi_chan_list_dump_lli (struct axi_dma_chan *chan,struct axi_dma_desc *desc_head) { -int count =atomic_read (&chan->descs_allocated); -int i; - -for (i =0 ; i < count; i++) +for (unsigned int i =0 ; i < desc_head->nr_hw_descs; i++)axi_chan_dump_lli (chan, &desc_head->hw_desc[i]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/1756 dmaengine: dw-axi-dmac: Fix CH_CFG2 channel priority position
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit 2a9013c20c46216b92ff09e2283b5244a91c59da ]
The CH_CFG2 channel priority field occupies bits 51:47 of the 64-bit channel configuration register, corresponding to bits 19:15 of CH_CFG2_H.
The driver currently shifts the priority value by 20, programming the wrong bits. Use bit 15 as the field position.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac.h +1 -1
@@ -325,7 +325,7 @@ enum {#define CH_CFG2_H_TT_FC_POS 0#define CH_CFG2_H_HS_SEL_SRC_POS 3#define CH_CFG2_H_HS_SEL_DST_POS 4 -#define CH_CFG2_H_PRIORITY_POS 20 +#define CH_CFG2_H_PRIORITY_POS 15/** * DW AXI DMA channel interrupts
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/1756 PCI: endpoint: pci-epf-vntb: Serialize virtual PCI bus scan
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit 84c3520c9e8c14b09a5cf645cc4fa7c6d9d61127 ]
The virtual PCI bus is scanned without holding the PCI rescan/remove lock. This can race with other PCI topology changes.
Hold the lock across the bus scan and device addition.
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/endpoint/functions/pci-epf-vntb.c +5 -0
@@ -1008,15 +1008,20 @@ static int vpci_scan_bus(void *sysdata)struct pci_bus *vpci_bus;struct epf_ntb *ndev = sysdata; +pci_lock_rescan_remove (); + vpci_bus =pci_scan_bus (ndev->vbus_number, &vpci_ops, sysdata);if (!vpci_bus) {pr_err ("create pci bus failed\n" ); +pci_unlock_rescan_remove ();return -EINVAL ; } ndev->vpci_bus = vpci_bus;pci_bus_add_devices (vpci_bus); +pci_unlock_rescan_remove (); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/1756 regulator: ab8500: Fix AB8505 VANA voltage selectors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit dfdfda2a95843706428a9d95ab546cb10983e684 ]
The AB8505 VANA voltage table assumes selector 0 represents 1.05 V and all eight selectors increase linearly. Selector 0 actually represents 1.2 V. Selectors 1 through 6 cover 1.05 V through 1.175 V, and selector 7 represents 1.225 V.
Correct the table so each selector reports and programs the documented voltage.
Reference: AB8505 User Manual, DM00046744 Rev 3, p. 257
--- drivers/regulator/ab8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/ab8500.c +1 -1
@@ -265,13 +265,13 @@ static const unsigned int fixed_2050000_voltage[] = { };static const unsigned int ldo_vana_voltages[] = { +1200000 ,1050000 ,1075000 ,1100000 ,1125000 ,1150000 ,1175000 , -1200000 ,1225000 , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/1756 regulator: ab8500: Remove stale expand_register kernel-doc entry
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit 0991f3b4624ed713d1d5eb56520c1c9b2deaab7a ]
Commit aeee55b76bfd ("regulator: ab8500: Remove unused embedded struct expand_register") deleted the expand_register member from struct ab8500_regulator_info and, in the same hunk, added an empty "@expand_register:" line to the kernel-doc block. That traded one W=1 warning for another:
drivers/regulator/ab8500.c:196 Excess struct member 'expand_register' description in 'ab8500_regulator_info'
Drop the leftover line; the remaining @member entries all match the struct.
No functional changes.
Stable-dep-of: ac72c091a981 ("regulator: ab8500: Add AB8505 VAUX3 3.05 V setting")
--- drivers/regulator/ab8500.c | 1 - 1 file changed, 1 deletion(-)
drivers/regulator/ab8500.c +0 -1
@@ -173,7 +173,6 @@ struct ab8500_shared_mode {* @voltage_bank: bank to control regulator voltage * @voltage_reg: register to control regulator voltage * @voltage_mask: mask to control regulator voltage -* @expand_register: */ struct ab8500_regulator_info {struct device *dev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/1756 regulator: ab8500: Add AB8505 VAUX3 3.05 V setting
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit ac72c091a9810493ccd9209414d4f859276727ab ]
AB8505 has an additional VAUX3 voltage setting which is not encoded in the normal three-bit selector. ArmRegu2.Vaux3Sel3 overrides that selector and selects 3.05 V.
Add the missing voltage and use the override bit as an extended selector. Program the ordinary selector before clearing the override so VAUX3 does not briefly switch to a stale voltage.
Reference: AB8505 User Manual, DM00046744 Rev 3, pp. 229 and 254
--- drivers/regulator/ab8500.c | 101 +++++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 3 deletions(-)
drivers/regulator/ab8500.c +98 -3
@@ -173,6 +173,7 @@ struct ab8500_shared_mode {* @voltage_bank: bank to control regulator voltage * @voltage_reg: register to control regulator voltage * @voltage_mask: mask to control regulator voltage +* @expand_register: additional register used to select an extra voltage */ struct ab8500_regulator_info {struct device *dev;
@@ -193,6 +194,12 @@ struct ab8500_regulator_info {u8 voltage_bank;u8 voltage_reg;u8 voltage_mask; +struct { +u8 voltage_limit; +u8 voltage_bank; +u8 voltage_reg; +u8 voltage_mask; + } expand_register; };/* voltage tables for the vauxn/vintcore supplies */
@@ -226,6 +233,18 @@ static const unsigned int ldo_vaux3_voltages[] = { 2910000, }; +static const unsigned int ldo_vaux3_ab8505_voltages[] = { +1200000 , +1500000 , +1800000 , +2100000 , +2500000 , +2750000 , +2790000 , +2910000 , +3050000 , +}; +static const unsigned int ldo_vaux56_voltages[] = {1800000 ,1050000 ,
@@ -593,6 +612,64 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,return ret; } +static int ab8500_regulator_get_voltage_sel_expand (struct regulator_dev *rdev) +{ +struct ab8500_regulator_info *info =rdev_get_drvdata (rdev); +u8 regval; +int ret; + +if (!info) +return -EINVAL ; + + ret =abx500_get_register_interruptible (info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, ®val); +if (ret <0 ) { +dev_err (rdev_get_dev (rdev), +"couldn't read voltage expand reg for regulator\n" ); +return ret; + } + +if (regval & info->expand_register.voltage_mask) +return info->expand_register.voltage_limit; + +return ab8500_regulator_get_voltage_sel (rdev); +} + +static int ab8500_regulator_set_voltage_sel_expand (struct regulator_dev *rdev, +unsigned int selector) +{ +struct ab8500_regulator_info *info =rdev_get_drvdata (rdev); +u8 regval; +int ret; + +if (!info) +return -EINVAL ; + +if (selector > info->expand_register.voltage_limit) +return -EINVAL ; + +if (selector < info->expand_register.voltage_limit) { + ret =ab8500_regulator_set_voltage_sel (rdev, selector); +if (ret <0 ) +return ret; + + regval =0 ; + }else { + regval = info->expand_register.voltage_mask; + } + + ret =abx500_mask_and_set_register_interruptible (info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, + info->expand_register.voltage_mask, regval); +if (ret <0 ) +dev_err (rdev_get_dev (rdev), +"couldn't set voltage expand reg for regulator\n" ); + +return ret; +} +static const struct regulator_ops ab8500_regulator_volt_mode_ops = { .enable = ab8500_regulator_enable, .disable = ab8500_regulator_disable,
@@ -605,6 +682,18 @@ static const struct regulator_ops ab8500_regulator_volt_mode_ops = { .list_voltage = regulator_list_voltage_table, }; +static const struct regulator_ops ab8500_regulator_volt_mode_expand_ops = { + .enable = ab8500_regulator_enable, + .disable = ab8500_regulator_disable, + .is_enabled = ab8500_regulator_is_enabled, + .get_optimum_mode = ab8500_regulator_get_optimum_mode, + .set_mode = ab8500_regulator_set_mode, + .get_mode = ab8500_regulator_get_mode, + .get_voltage_sel = ab8500_regulator_get_voltage_sel_expand, + .set_voltage_sel = ab8500_regulator_set_voltage_sel_expand, + .list_voltage = regulator_list_voltage_table, +}; +static const struct regulator_ops ab8500_regulator_volt_ops = { .enable = ab8500_regulator_enable, .disable = ab8500_regulator_disable,
@@ -908,12 +997,12 @@ static struct ab8500_regulator_info [AB8505_LDO_AUX3] = { .desc = { .name = "LDO-AUX3", - .ops = &ab8500_regulator_volt_mode_ops, + .ops = &ab8500_regulator_volt_mode_expand_ops, .type = REGULATOR_VOLTAGE, .id = AB8505_LDO_AUX3, .owner = THIS_MODULE, - .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), - .volt_table = ldo_vaux3_voltages, + .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8505_voltages), + .volt_table = ldo_vaux3_ab8505_voltages, }, .load_lp_uA = 5000, .update_bank = 0x04,
@@ -925,6 +1014,12 @@ static struct ab8500_regulator_info .voltage_bank = 0x04, .voltage_reg = 0x21, .voltage_mask = 0x07, + .expand_register = { + .voltage_limit = 8, + .voltage_bank = 0x04, + .voltage_reg = 0x01, + .voltage_mask = 0x10, + }, }, [AB8505_LDO_AUX4] = { .desc = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/1756 regulator: ab8500: Handle AB8505 VINTCORE selector 7
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 4ec4df7e54182edb6955caace37684e535e462dc ]
The AB8505 VINTCORE table exposes only selectors 0 through 6. The hardware also accepts selector 7 and maps it to 1.35 V, just like selector 6. Omitting it can make an OTP-programmed selector 7 appear invalid to the regulator core.
Give AB8505 its own eight-entry selector table while leaving the AB8500 table unchanged.
Reference: AB8505 User Manual, DM00046744 Rev 3, p. 223
--- drivers/regulator/ab8500.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/regulator/ab8500.c +13 -2
@@ -266,6 +266,17 @@ static const unsigned int ldo_vintcore_voltages[] = { 1350000, }; +static const unsigned int ldo_vintcore_ab8505_voltages[] = { +1200000 , +1225000 , +1250000 , +1275000 , +1300000 , +1325000 , +1350000 , +1350000 , +}; +static const unsigned int fixed_1200000_voltage[] = {1200000 , };
@@ -1095,8 +1106,8 @@ static struct ab8500_regulator_info .type = REGULATOR_VOLTAGE, .id = AB8505_LDO_INTCORE, .owner = THIS_MODULE, - .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), - .volt_table = ldo_vintcore_voltages, + .n_voltages = ARRAY_SIZE(ldo_vintcore_ab8505_voltages), + .volt_table = ldo_vintcore_ab8505_voltages, }, .load_lp_uA = 5000, .update_bank = 0x03,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/1756 regulator: ab8500: Treat cut 1.0 VAUX3 as fixed
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b9fc8a8d31b914b09329240f532ff0e9c00cd727 ]
The early-cut workaround currently gives AB8500 cut 1.0 the 16 programmable VAUX3 settings introduced with cut 1.1. On cut 1.0 the selector is not programmable and VAUX3 is fixed at 1.2 V.
Register VAUX3 as a fixed-voltage regulator on cut 1.0 and retain the 16-value workaround only for cut 1.1.
Reference: AB8500 User Manual, UM0836 Rev 3, p. 240
--- drivers/regulator/ab8500.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/regulator/ab8500.c +8 -3
@@ -1783,9 +1783,14 @@ static int ab8500_regulator_register(struct platform_device *pdev, config.driver_data = info; config.of_node = np; -/* fix for hardware before ab8500v2.0 */ -if (is_ab8500_1p1_or_earlier (ab8500)) { -if (info->desc.id ==AB8500_LDO_AUX3 ) { +/* Handle the different VAUX3 implementations in early AB8500 cuts. */ +if (info->desc.id ==AB8500_LDO_AUX3 ) { +if (is_ab8500_1p0_or_earlier (ab8500)) { + info->desc.ops = &ab8500_regulator_mode_ops; + info->desc.n_voltages =1 ; + info->desc.volt_table = fixed_1200000_voltage; + info->voltage_mask =0 ; + }else if (is_ab8500_1p1_or_earlier (ab8500)) { info->desc.n_voltages =ARRAY_SIZE (ldo_vauxn_voltages); info->desc.volt_table = ldo_vauxn_voltages;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/1756 regulator: ab8500: Test dedicated enable bits only
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit a5ee78846015512b4d3d32f8aa463024a23234ce ]
Some regulator control registers have independent enable and low-power bits. is_enabled() currently tests their combined update mask, so an off regulator with its low-power bit set is incorrectly reported as enabled.
Add an optional enable mask and use it for VINTCORE, AB8500 TVOUT, AB8505 ADC, and AB8505 VAUX5/6. Regulators whose two-bit field encodes the complete operating state continue to test the full update mask.
References: AB8500 User Manual, UM0836 Rev 3, p. 214; AB8505 User Manual, DM00046744 Rev 3, pp. 171-172 and 223
--- drivers/regulator/ab8500.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/regulator/ab8500.c +13 -2
@@ -162,6 +162,7 @@ struct ab8500_shared_mode {* @update_bank: bank to control on/off * @update_reg: register to control on/off * @update_mask: mask to enable/disable and set mode of regulator +* @enable_mask: optional mask for an enable bit separate from the mode bit * @update_val: bits holding the regulator current mode * @update_val_idle: bits to enable the regulator in idle (low power) mode * @update_val_normal: bits to enable the regulator in normal (high power) mode
@@ -183,6 +184,7 @@ struct ab8500_regulator_info {u8 update_bank;u8 update_reg;u8 update_mask; +u8 enable_mask;u8 update_val;u8 update_val_idle;u8 update_val_normal;
@@ -377,6 +379,7 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) {int ret;struct ab8500_regulator_info *info =rdev_get_drvdata (rdev); +u8 enable_mask;u8 regval;if (info ==NULL ) {
@@ -392,13 +395,15 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)return ret; } + enable_mask = info->enable_mask ? info->enable_mask : info->update_mask; +dev_vdbg (rdev_get_dev (rdev),"%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," " 0x%x\n" , info->desc.name, info->update_bank, info->update_reg, - info->update_mask, regval); + enable_mask, regval); -if (regval & info->update_mask) +if (regval & enable_mask)return 1 ;else return 0 ;
@@ -833,6 +838,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x44, + .enable_mask = 0x04, .update_val = 0x44, .update_val_idle = 0x44, .update_val_normal = 0x04,
@@ -861,6 +867,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x82, + .enable_mask = 0x02, .update_val = 0x02, .update_val_idle = 0x82, .update_val_normal = 0x02,
@@ -1070,6 +1077,7 @@ static struct ab8500_regulator_info .update_bank = 0x01, .update_reg = 0x55, .update_mask = 0x18, + .enable_mask = 0x10, .update_val = 0x10, .update_val_idle = 0x18, .update_val_normal = 0x10,
@@ -1092,6 +1100,7 @@ static struct ab8500_regulator_info .update_bank = 0x01, .update_reg = 0x56, .update_mask = 0x18, + .enable_mask = 0x10, .update_val = 0x10, .update_val_idle = 0x18, .update_val_normal = 0x10,
@@ -1113,6 +1122,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x44, + .enable_mask = 0x04, .update_val = 0x04, .update_val_idle = 0x44, .update_val_normal = 0x04,
@@ -1141,6 +1151,7 @@ static struct ab8500_regulator_info .update_bank = 0x03, .update_reg = 0x80, .update_mask = 0x82, + .enable_mask = 0x02, .update_val = 0x02, .update_val_idle = 0x82, .update_val_normal = 0x02,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/1756 regulator: ab8500: Propagate mode enable read errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 71ac8878573058e2b85210760ccaeaac90796c35 ]
For regulators whose enable and mode share a state field, set_mode() first reads that field so changing the requested mode does not enable a disabled rail. A register read error is currently treated as true and the driver proceeds to write the new mode, potentially enabling a rail whose state is unknown.
Return the read error without changing the register or cached mode.
References: AB8500 User Manual, UM0836 Rev 3, p. 227; AB8505 User Manual, DM00046744 Rev 3, p. 237
--- drivers/regulator/ab8500.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/regulator/ab8500.c +12 -2
@@ -433,7 +433,7 @@ static unsigned int ab8500_regulator_get_optimum_mode(static int ab8500_regulator_set_mode (struct regulator_dev *rdev,unsigned int mode) { -int ret =0 ; +int enabled, ret =0 ;u8 bank, reg, mask, val;bool lp_mode_req = false;struct ab8500_regulator_info *info =rdev_get_drvdata (rdev);
@@ -490,7 +490,17 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev, goto out_unlock; } -if (info->mode_mask ||ab8500_regulator_is_enabled (rdev)) { +if (info->mode_mask) { + enabled =1 ; + }else { + enabled =ab8500_regulator_is_enabled (rdev); +if (enabled <0 ) { + ret = enabled; + goto out_unlock; + } + } + +if (enabled) { ret =abx500_mask_and_set_register_interruptible (info->dev, bank, reg, mask, val);if (ret <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/1756 arm64: dts: qcom: sm7225-fairphone-fp4: Disable PMK8350 PON
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 5c088a33e3a9bb236c475b7230df275fc1e51eda ]
Two PMICs on this phone have a PON block, the PM6350 and PMK8350. Only one should be enabled at one time, so disable PMK8350 PON and keep the PM6350 PON.
--- arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts +4 -0
@@ -924,6 +924,10 @@ xo-therm@0 { }; }; +&pmk8350_pon { + status = "disabled"; +}; + &pmk8350_rtc { status = "okay"; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/1756 sit: fix UAF in ipip6_tunnel_del_prl()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 5145bb6a2c2683d541828f86d5321e0565f2e30c ]
When flushing all potential router list (PRL) entries, ipip6_tunnel_del_prl() called call_rcu(&x->rcu_head, prl_list_destroy_rcu) before clearing t->prl.
A concurrent reader in isatap_chksrc() could enter an RCU read-side critical section after call_rcu() but before t->prl is set to NULL, allowing prl_list_destroy_rcu() to free nodes while the reader traverses them.
Clear t->prl using RCU_INIT_POINTER() before invoking call_rcu(). Also use rcu_assign_pointer() when unlinking individual entries.
--- net/ipv6/sit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/sit.c +2 -2
@@ -435,7 +435,7 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) (x =rtnl_dereference (*p)) !=NULL ; p = &x->next) {if (x->addr == a->addr) { - *p = x->next; +rcu_assign_pointer (*p,rtnl_dereference (x->next));kfree_rcu (x, rcu_head); t->prl_count--; goto out;
@@ -446,8 +446,8 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) x =rtnl_dereference (t->prl);if (x) { t->prl_count =0 ; +RCU_INIT_POINTER (t->prl,NULL );call_rcu (&x->rcu_head, prl_list_destroy_rcu); - t->prl =NULL ; } } out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/1756 ip_tunnel: use WRITE_ONCE in ip_tunnel_encap_setup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 88b84cae6b94087d3a9679845fe28ad19c7bef8b ]
Update ip_tunnel_encap_setup() to use WRITE_ONCE() when writing to encap fields (type, sport, dport, flags) and hlen fields. This ensures that concurrent lockless readers (like fill_info) do not see torn writes.
Also remove the unsafe memset() on t->encap which could cause concurrent readers to transiently see zeroed fields. Removing it also fixes a bug where t->encap was left cleared even if ip_encap_hlen() failed, resulting in partial configuration.
--- net/ipv4/ip_tunnel.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/ipv4/ip_tunnel.c +6 -8
@@ -490,19 +490,17 @@ int ip_tunnel_encap_setup(struct ip_tunnel *t, {int hlen; -memset (&t->encap,0 ,sizeof (t->encap)); - hlen =ip_encap_hlen (ipencap);if (hlen <0 )return hlen; - t->encap.type = ipencap->type; - t->encap.sport = ipencap->sport; - t->encap.dport = ipencap->dport; - t->encap.flags = ipencap->flags; +WRITE_ONCE (t->encap.type, ipencap->type); +WRITE_ONCE (t->encap.sport, ipencap->sport); +WRITE_ONCE (t->encap.dport, ipencap->dport); +WRITE_ONCE (t->encap.flags, ipencap->flags); - t->encap_hlen = hlen; - t->hlen = t->encap_hlen + t->tun_hlen; +WRITE_ONCE (t->encap_hlen, hlen); +WRITE_ONCE (t->hlen, hlen + t->tun_hlen);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/1756 crypto: amlogic - Fix DMA memory leak in cipher error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Raizudeen <[email protected]>
[ Upstream commit 6c2373dd818b777d0a81eb02acebc03940552dcd ]
A DMA memory leak occurs in meson_cipher() on the mapping error paths. The driver jumps to the end of the function without unmapping the previously mapped source scatterlist and key/IV buffer when the destination apping fails.
Additionally, a memory leak occurs when a scatterlist mapping succeeds but the returned count exceeds the driver's MAXDESC limit. In this case, the driver rejects the mapping without unmapping it. The BIDIRECTIONAL mapping branch also lacks the required 'MAXDESC -3' upper bound check.
Fix this by introducing proper error labels, error_src and error_keyiv and unmap resources immediately inside the calidation checks to ensure all successfully mapped resources are cleaned up before returning the error.
--- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 25 ++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/crypto/amlogic/amlogic-gxl-cipher.c +20 -5
@@ -177,10 +177,13 @@ static int meson_cipher(struct skcipher_request *areq)if (areq->src == areq->dst) { nr_sgs =dma_map_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_BIDIRECTIONAL ); -if (!nr_sgs) { -dev_err (mc->dev,"Invalid SG count %d\n" , nr_sgs); +if (!nr_sgs || nr_sgs >MAXDESC -3 ) { +dev_err (mc->dev,"Invalid BIDIR SG count %d\n" , nr_sgs); err = -EINVAL ; - goto theend; + +if (nr_sgs) +dma_unmap_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_BIDIRECTIONAL ); + goto error_keyiv; } nr_sgd = nr_sgs; }else {
@@ -189,14 +192,20 @@ static int meson_cipher(struct skcipher_request *areq)if (!nr_sgs || nr_sgs >MAXDESC -3 ) {dev_err (mc->dev,"Invalid SG count %d\n" , nr_sgs); err = -EINVAL ; - goto theend; + +if (nr_sgs) +dma_unmap_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_TO_DEVICE ); + goto error_keyiv; } nr_sgd =dma_map_sg (mc->dev, areq->dst,sg_nents (areq->dst),DMA_FROM_DEVICE );if (!nr_sgd || nr_sgd >MAXDESC -3 ) {dev_err (mc->dev,"Invalid SG count %d\n" , nr_sgd); err = -EINVAL ; - goto theend; + +if (nr_sgd) +dma_unmap_sg (mc->dev, areq->dst,sg_nents (areq->dst),DMA_FROM_DEVICE ); + goto error_src; } }
@@ -251,6 +260,12 @@ static int meson_cipher(struct skcipher_request *areq) ivsize, 0); } } + goto theend; + +error_src: +dma_unmap_sg (mc->dev, areq->src,sg_nents (areq->src),DMA_TO_DEVICE ); +error_keyiv: +dma_unmap_single (mc->dev, phykeyiv, keyivlen,DMA_TO_DEVICE ); theend:kfree_sensitive (bkeyiv);kfree_sensitive (backup_iv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/1756 crypto: qat - avoid OOB read when stripping RSA leading zeros
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit ac508238898058f0b09b18a7891fb31279617781 ]
The logical AND operator uses short-circuit evaluation: the first operand is always evaluated, while the second is evaluated only if the first is true. Because the first operand dereferences a pointer, it may cause an out-of-bounds access before the bounds check in the second operand is evaluated.
Resolve this by checking the vlen prior to the pointer being dereferenced.
--- drivers/crypto/intel/qat/qat_common/qat_asym_algs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/intel/qat/qat_common/qat_asym_algs.c +4 -4
@@ -987,7 +987,7 @@ static int qat_rsa_set_n(struct qat_rsa_ctx *ctx, const char *value,const char *ptr = value;int ret; -while (!*ptr && vlen) { +while (vlen && !*ptr) { ptr++; vlen--; }
@@ -1018,7 +1018,7 @@ static int qat_rsa_set_e(struct qat_rsa_ctx *ctx, const char *value,struct device *dev = &GET_DEV (inst->accel_dev);const char *ptr = value; -while (!*ptr && vlen) { +while (vlen && !*ptr) { ptr++; vlen--; }
@@ -1044,7 +1044,7 @@ static int qat_rsa_set_d(struct qat_rsa_ctx *ctx, const char *value,const char *ptr = value;int ret; -while (!*ptr && vlen) { +while (vlen && !*ptr) { ptr++; vlen--; }
@@ -1067,7 +1067,7 @@ static int qat_rsa_set_d(struct qat_rsa_ctx *ctx, const char *value,static void qat_rsa_drop_leading_zeros (const char **ptr,unsigned int *len) { -while (!**ptr && *len) { +while (*len && !**ptr) { (*ptr)++; (*len)--; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/1756 crypto: qat - release instance on DH fallback allocation failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 307e27d3e07f58b6d42a8c64d31304aa614ab7d2 ]
qat_dh_init_tfm() acquires a QAT crypto instance before allocating the software fallback transform. If fallback allocation fails, the instance reference is leaked and the device remains permanently in use.
Release the instance before returning the allocation error.
--- drivers/crypto/intel/qat/qat_common/qat_asym_algs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/qat_asym_algs.c +3 -1
@@ -535,8 +535,10 @@ static int qat_dh_init_tfm(struct crypto_kpp *tfm)return -EINVAL ; ctx->ftfm =crypto_alloc_kpp (alg,0 ,CRYPTO_ALG_NEED_FALLBACK ); -if (IS_ERR (ctx->ftfm)) +if (IS_ERR (ctx->ftfm)) { +qat_crypto_put_instance (inst);return PTR_ERR (ctx->ftfm); + }crypto_kpp_set_flags (ctx->ftfm,crypto_kpp_get_flags (tfm));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/1756 crypto: mxs-dcp - handle zero-length skcipher requests
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit ac1d6a65a1e1f069f119df42c6b57dbdff5f6be8 ]
Zero-length skcipher requests are valid no-ops, but MXS-DCP queues them. When such a request reaches the worker, last_out_len remains zero. The CBC completion path then subtracts AES_BLOCK_SIZE from this unsigned value when updating the IV, causing the offset to underflow. On decryption, the resulting source address precedes aes_in_buf.
Return success before enqueueing zero-length requests. This avoids the invalid source access and leaves the IV unchanged for a no-op.
--- drivers/crypto/mxs-dcp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/mxs-dcp.c +3 -0
@@ -473,6 +473,9 @@ static int mxs_dcp_aes_enqueue(struct skcipher_request *req, int enc, int ecb)struct dcp_aes_req_ctx *rctx =skcipher_request_ctx (req);int ret; +if (!req->cryptlen) +return 0 ; +if (unlikely (actx->key_len !=AES_KEYSIZE_128 && !actx->key_referenced))return mxs_dcp_block_fallback (req, enc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/1756 crypto: lskcipher - preserve state across unaligned chunks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit ba871255f796d1f599ba710f03e1803d1b374a75 ]
crypto_lskcipher_crypt_unaligned() splits a request into page-sized chunks but never sets CRYPTO_LSKCIPHER_FLAG_CONT, so a stateful algorithm restarts from its keyed state at every page boundary. It also marks every chunk CRYPTO_LSKCIPHER_FLAG_FINAL, which is wrong but harmless: chunks are trimmed to a multiple of the chunk size, so the trailing partial block that FINAL guards against is caught after the loop instead.
ARC4 is the only lskcipher with internal state, and cbc, the other in-tree user of the direct API, never passes more than one block, so this went unnoticed. bpf_crypto_crypt() however hands __bpf_dynptr_data() to crypto_lskcipher_encrypt() unchecked, leaving both alignment and length to the BPF program. An 8192-byte ARC4 request offset by one byte comes back with its second page identical to its
first: the keystream is reused.
Set FINAL only on the last chunk and CONT after the first, mirroring the progression used by crypto_lskcipher_crypt_sg().
--- crypto/lskcipher.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
crypto/lskcipher.c +5 -1
@@ -75,6 +75,7 @@ static int crypto_lskcipher_crypt_unaligned(unsigned ivsize =crypto_lskcipher_ivsize (tfm);unsigned bs =crypto_lskcipher_blocksize (tfm);unsigned cs =crypto_lskcipher_chunksize (tfm); +u32 flags =0 ;int err;u8 *tiv;u8 *p;
@@ -98,13 +99,16 @@ static int crypto_lskcipher_crypt_unaligned(if (chunk > cs) chunk &= ~(cs -1 ); +if (chunk == len) + flags |=CRYPTO_LSKCIPHER_FLAG_FINAL ;memcpy (p, src, chunk); - err =crypt (tfm, p, p, chunk, tiv,CRYPTO_LSKCIPHER_FLAG_FINAL ); + err =crypt (tfm, p, p, chunk, tiv, flags);if (err) goto out;memcpy (dst, p, chunk); + flags |=CRYPTO_LSKCIPHER_FLAG_CONT ; src += chunk; dst += chunk; len -= chunk;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/1756 memory: exynos5422-dmc: handle clock enable failures
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Liu <[email protected]>
[ Upstream commit cce46902ea9fcd585cd200fffa3166f63bc571f1 ]
Check the return values of clk_prepare_enable() for fout_bpll and mout_bpll.
If enabling fout_bpll fails, propagate the error. If enabling mout_bpll fails, disable fout_bpll before returning. This keeps the clock enable count balanced on probe error paths.
--- drivers/memory/samsung/exynos5422-dmc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/memory/samsung/exynos5422-dmc.c +9 -2
@@ -1297,8 +1297,15 @@ static int exynos5_dmc_init_clks(struct exynos5_dmc *dmc)if (ret)return ret; -clk_prepare_enable (dmc->fout_bpll); -clk_prepare_enable (dmc->mout_bpll); + ret =clk_prepare_enable (dmc->fout_bpll); +if (ret) +return ret; + + ret =clk_prepare_enable (dmc->mout_bpll); +if (ret) { +clk_disable_unprepare (dmc->fout_bpll); +return ret; + }/* * Some bootloaders do not set clock routes correctly.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/1756 gfs2: Fix journaled truncate range end offset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit a52652efd8f985397e87669f505af83f06e335cf ]
The third argument to truncate_pagecache_range() is the inclusive end offset, but gfs2_journaled_truncate_range() passes the length of each chunk. A hole punch at an offset larger than its length therefore creates an inverted range.
Commit 86066914edff ("gfs2: Don't support fallocate on jdata files") disables fallocate for jdata files. Otherwise, the following bug could occur:
The MM truncation path then underflows the unsigned partial-folio length and passes an oversized range to folio_zero_range(), triggering a BUG. Pass the last byte of the chunk so page-cache invalidation covers the intended range.
--- fs/gfs2/bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/bmap.c +1 -1
@@ -2407,7 +2407,7 @@ static int gfs2_journaled_truncate_range(struct inode *inode, loff_t offset,if (offs && chunk >PAGE_SIZE ) chunk = offs + ((chunk - offs) &PAGE_MASK ); -truncate_pagecache_range (inode, offset, chunk); +truncate_pagecache_range (inode, offset, offset + chunk -1 ); offset += chunk; length -= chunk;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/1756 ACPI: glue: Fix up and adjust acpi_unbind_one()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 693546852656075e0247ac637b05625ead134eff ]
Since none of the acpi_unbind_one() callers check its return value and it always returns 0 anyway, make it void.
Also notice that unlocking physical_node_lock for the given ACPI device should be carried out before dropping the reference to it in case that reference is the last one (highly unlikely), so rearrange the code to make that happen.
--- drivers/acpi/glue.c | 10 ++++++---- include/acpi/acpi_bus.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/acpi/glue.c +6 -4
@@ -316,13 +316,13 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) }EXPORT_SYMBOL_GPL (acpi_bind_one); -int acpi_unbind_one (struct device *dev) +void acpi_unbind_one (struct device *dev) {struct acpi_device *acpi_dev =ACPI_COMPANION (dev);struct acpi_device_physical_node *entry;if (!acpi_dev) -return 0 ; +return ;mutex_lock (&acpi_dev->physical_node_lock);
@@ -337,15 +337,17 @@ int acpi_unbind_one(struct device *dev)sysfs_remove_link (&acpi_dev->dev.kobj, physnode_name);sysfs_remove_link (&dev->kobj,"firmware_node" );ACPI_COMPANION_SET (dev,NULL ); + +mutex_unlock (&acpi_dev->physical_node_lock); +/* Drop references taken by acpi_bind_one(). */ put_device (dev);acpi_dev_put (acpi_dev);kfree (entry); -break ; +return ; }mutex_unlock (&acpi_dev->physical_node_lock); -return 0 ; }EXPORT_SYMBOL_GPL (acpi_unbind_one);
include/acpi/acpi_bus.h +1 -1
@@ -720,7 +720,7 @@ struct acpi_bus_type {int register_acpi_bus_type (struct acpi_bus_type *);int unregister_acpi_bus_type (struct acpi_bus_type *);int acpi_bind_one (struct device *dev,struct acpi_device *adev); -int acpi_unbind_one (struct device *dev); +void acpi_unbind_one (struct device *dev);enum acpi_bridge_type {ACPI_BRIDGE_TYPE_PCIE =1 ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/1756 thermal: gov_power_allocator: Fix NULL pointer dereference in update_tz()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumeet Pawnikar <[email protected]>
[ Upstream commit d3515092f1bff9cfb4d99ea82dcd4ac66f32f50d ]
power_allocator_update_tz() unconditionally derives the trip descriptor of params->trip_max as below,
const struct thermal_trip_desc *td = trip_to_trip_desc(params->trip_max);
and then walks td->thermal_instances. However, params->trip_max is allowed to be NULL and in that case the list walk dereferences a bogus pointer derived from NULL which oops the kernel.
get_governor_trips() picks trip_switch_on and trip_max out of the trip table of the zone. When the zone has neither a passive nor an active trip point, last_active is NULL and params->trip_max is left NULL. This is an explicitly supported configuration, as documented in the function get_governor_trips() as below,
If there are no passive or active trip points, then the governor won't do anything. In fact, its throttle function won't be called at all.
Return early from power_allocator_update_tz() when params->trip_max is NULL and only compute the trip descriptor after that check. There is nothing to update in that case anyway, with no trip_max and there are no thermal instances for the governor to account for, num_actors stays zero and total_weight is irrelevant.
--- drivers/thermal/gov_power_allocator.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/thermal/gov_power_allocator.c +6 -1
@@ -655,10 +655,15 @@ static void power_allocator_update_tz(struct thermal_zone_device *tz, enum thermal_notify_event reason) {struct power_allocator_params *params = tz->governor_data; -const struct thermal_trip_desc *td =trip_to_trip_desc (params->trip_max); +const struct thermal_trip_desc *td;struct thermal_instance *instance;int num_actors =0 ; +if (!params->trip_max) +return ; + + td =trip_to_trip_desc (params->trip_max); +switch (reason) {case THERMAL_TZ_BIND_CDEV :case THERMAL_TZ_UNBIND_CDEV :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/1756 firewire: cdev: Fix FW_CDEV_IOC_CREATE_ISO_CONTEXT references in kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 0a6cf2b7adcbd362039e9d282f73aff3f24022ca ]
The fw_cdev_event_iso_interrupt and fw_cdev_event_iso_interrupt_mc comments refer to FW_CDEV_CREATE_ISO_CONTEXT, but the ioctl is named FW_CDEV_IOC_CREATE_ISO_CONTEXT.
Correct both references. The misspellings were introduced separately with the userspace interface documentation and multichannel reception support.
--- include/uapi/linux/firewire-cdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/firewire-cdev.h +2 -2
@@ -293,7 +293,7 @@ struct fw_cdev_event_request3 {/** * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed * @closure: See &fw_cdev_event_common; -* set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl +* set by %FW_CDEV_IOC_CREATE_ISO_CONTEXT ioctl * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT * @cycle: Cycle counter of the last completed packet * @header_length: Total length of following headers, in bytes
@@ -353,7 +353,7 @@ struct fw_cdev_event_iso_interrupt {/** * struct fw_cdev_event_iso_interrupt_mc - An iso buffer chunk was completed * @closure: See &fw_cdev_event_common; -* set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl +* set by %FW_CDEV_IOC_CREATE_ISO_CONTEXT ioctl * @type: %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL * @completed: Offset into the receive buffer; data before this offset is valid *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/1756 firewire: core: remove unused link field in fw_packet structure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 00d4d31e4fdfe51312f0184f8d162b8d4de172dc ]
The link field in fw_packet structure has never been used since it was added.
--- include/linux/firewire.h | 1 - 1 file changed, 1 deletion(-)
include/linux/firewire.h +0 -1
@@ -312,7 +312,6 @@ struct fw_packet {*/ fw_packet_callback_t callback;int ack; -struct list_head link;void *driver_data; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/1756 cpuidle: menu: Remove incorrect unlikely() annotation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit fcbd7897b871e157ee5c595e950c8466d86c0cd5 ]
The unlikely() annotation on the early-return condition in menu_select() is incorrect on systems with only one idle state (e.g., ARM64 servers with a single ACPI LPI state). Branch profiling shows 100% misprediction on such systems since drv->state_count <= 1 is always true.
On platforms where only state0 is available, this path is the common case, not an unlikely edge case. Remove the misleading annotation to let the branch predictor learn the actual behavior.
Stable-dep-of: d594187cafd5 ("cpuidle: menu: Do not return a disabled idle state")
--- drivers/cpuidle/governors/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/governors/menu.c +1 -1
@@ -287,7 +287,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, data->bucket =which_bucket (KTIME_MAX ); } -if (unlikely (drv->state_count <=1 || latency_req ==0 ) || +if (drv->state_count <=1 || latency_req ==0 || ((data->next_timer_ns < drv->states[1 ].target_residency_ns || latency_req < drv->states[1 ].exit_latency_ns) && !dev->states_usage[0 ].disable)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/1756 cpuidle: menu: Remove single state handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Loehle <[email protected]>
[ Upstream commit 93983a9f3beea791c21d77c2425488ad327d4fda ]
cpuidle systems where the governor has no choice because there's only a single idle state are now handled by cpuidle core and bypass the governor, so remove the related handling.
Stable-dep-of: d594187cafd5 ("cpuidle: menu: Do not return a disabled idle state")
--- drivers/cpuidle/governors/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/governors/menu.c +1 -1
@@ -287,7 +287,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, data->bucket =which_bucket (KTIME_MAX ); } -if (drv->state_count <=1 || latency_req ==0 || +if (latency_req ==0 || ((data->next_timer_ns < drv->states[1 ].target_residency_ns || latency_req < drv->states[1 ].exit_latency_ns) && !dev->states_usage[0 ].disable)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/1756 cpuidle: menu: Do not return a disabled idle state
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit d594187cafd5ad65afc5f00242f8fa20e1d8c0f1 ]
When idle state 0 is disabled and the PM QoS latency constraint is zero (latency_req == 0), the first branch of the || in the early-return condition of menu_select() is taken immediately, so state 0 is returned regardless of its disable flag.
Address this by making the !disable check a prerequisite for the entire early-return condition, so that when state 0 is disabled the normal state selection loop is used instead, which already skips disabled states.
--- drivers/cpuidle/governors/menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cpuidle/governors/menu.c +4 -4
@@ -287,10 +287,10 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, data->bucket =which_bucket (KTIME_MAX ); } -if (latency_req ==0 || - ((data->next_timer_ns < drv->states[1 ].target_residency_ns || - latency_req < drv->states[1 ].exit_latency_ns) && - !dev->states_usage[0 ].disable)) { +if (!dev->states_usage[0 ].disable && + (latency_req ==0 || + data->next_timer_ns < drv->states[1 ].target_residency_ns || + latency_req < drv->states[1 ].exit_latency_ns)) {/* * In this case state[0] will be used no matter what, so return * it right away and keep the tick running if state[0] is a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/1756 ARM: dts: stm32: lxa-mc1: change stdout-path baud rate from 9600 to 115200
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmad Fatoum <[email protected]>
[ Upstream commit fc3c0ffefc169719316eddb8c36e2427e11ce713 ]
The default baud rate when none is specified is up to the DT consumer.
In the case of the Linux STM32 serial driver, it defaults to 9600 baud, which differs from the 115200 baud that this board's barebox bootloader configured.
This went unnoticed, because barebox automatically fixes up a console= command-line option that looks like this on the LXA boards:
console=ttySTM0,115200n8
This had precedence over the 9600 fallback baud rate.
But when EFI booting a kernel via GRUB, we run into this issue, because the barebox-provided command-line is disregarded by GRUB.
Fix this by explicitly setting the baud rate to the correct 115200.
--- arch/arm/boot/dts/st/stm32mp157c-lxa-mc1.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/st/stm32mp157c-lxa-mc1.dts +1 -1
@@ -33,7 +33,7 @@ backlight: backlight { }; chosen { - stdout-path = &uart4; + stdout-path = "serial0:115200n8"; }; led-controller-0 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/1756 ARM: dts: stm32: lxa-tac: change stdout-path baud rate from 9600 to 115200
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmad Fatoum <[email protected]>
[ Upstream commit 85bb59fc12ef439b248d5f4faf846d5566b701fe ]
The default baud rate when none is specified is up to the DT consumer.
In the case of the Linux STM32 serial driver, it defaults to 9600 baud, which differs from the 115200 baud that this board's barebox bootloader configured.
This went unnoticed, because barebox automatically fixes up a console= command-line option that looks like this on the LXA boards:
console=ttySTM0,115200n8
This had precedence over the 9600 fallback baud rate.
But when EFI booting a kernel via GRUB, we run into this issue, because the barebox-provided command-line is disregarded by GRUB.
Fix this by explicitly setting the baud rate to the correct 115200.
--- arch/arm/boot/dts/st/stm32mp15xc-lxa-tac.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/st/stm32mp15xc-lxa-tac.dtsi +1 -1
@@ -25,7 +25,7 @@ aliases { }; chosen { - stdout-path = &uart4; + stdout-path = "serial0:115200n8"; }; led-controller-0 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 369/1756 ARM: dts: stm32: add LTDC / DCMIPP access controller for STM32MP135
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
[ Upstream commit 0c354b85cc95b5d563a581c8dbca57b4942bfae7 ]
Add ETZPC as an access controller for the LTDC and DCMIPP found on the stm32mp135.
--- arch/arm/boot/dts/st/stm32mp135.dtsi | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-)
arch/arm/boot/dts/st/stm32mp135.dtsi +21 -21
@@ -6,29 +6,29 @@ #include "stm32mp133.dtsi" -/ { - soc { - dcmipp: dcmipp@5a000000 { - compatible = "st,stm32mp13-dcmipp"; - reg = <0x5a000000 0x400>; - interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; - resets = <&rcc DCMIPP_R>; - clocks = <&rcc DCMIPP_K>; - status = "disabled"; +&etzpc { + dcmipp: dcmipp@5a000000 { + compatible = "st,stm32mp13-dcmipp"; + reg = <0x5a000000 0x400>; + interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; + resets = <&rcc DCMIPP_R>; + clocks = <&rcc DCMIPP_K>; + access-controllers = <&etzpc 4>; + status = "disabled"; - port { - }; + port { }; + }; - ltdc: display-controller@5a001000 { - compatible = "st,stm32-ltdc"; - reg = <0x5a001000 0x400>; - interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>, - <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&rcc LTDC_PX>; - clock-names = "lcd"; - resets = <&scmi_reset RST_SCMI_LTDC>; - status = "disabled"; - }; + ltdc: display-controller@5a001000 { + compatible = "st,stm32-ltdc"; + reg = <0x5a001000 0x400>; + interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&rcc LTDC_PX>; + clock-names = "lcd"; + resets = <&scmi_reset RST_SCMI_LTDC>; + access-controllers = <&etzpc 3>; + status = "disabled"; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/1756 cpuidle: teo: Do not return a disabled idle state
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit 60d5fca628f94f8f23398ad62d80aa284dae6571 ]
If idle state 0 is disabled and none of the enabled idle states satisfies the PM QoS latency constraint, constraint_idx in teo_select() stays at its initial value of 0, because the loop that updates it starts at state 1, and so the candidate state index is capped at state 0, which is disabled, and that state is returned to the caller.
The cpuidle core does not validate the returned state index against the per-state disable flags, so the CPU ends up entering the disabled state 0.
To address this, ensure that constraint_idx is at least equal to the index of the first enabled idle state (idx0), so that the candidate state is never capped to a disabled one.
--- drivers/cpuidle/governors/teo.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/cpuidle/governors/teo.c +11 -0
@@ -432,6 +432,17 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, goto out_tick; } +/* +* If the latency constraint does not allow any of the enabled idle +* states to be used, the candidate state index will be capped to 0 +* by the check below, but state 0 may be disabled. To prevent the +* selection of a disabled state in that case, ensure that +* constraint_idx is at least equal to the index of the first +* enabled idle state. +*/ +if (constraint_idx < idx0) + constraint_idx = idx0; +/* * If there is a latency constraint, it may be necessary to select an * idle state shallower than the current candidate one.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 371/1756 PM: runtime: Only queue an idle check for RPM-linked suppliers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Norris <[email protected]>
[ Upstream commit be5755f023e7e02ec90bbd1d4ca63a0abe594733 ]
When a device RPM-suspends, it queues up an idle check for all of its suppliers, in case that device was the last consumer, and those suppliers are now able to suspend. Today, we do this for all suppliers, and not only for those suppliers that are marked for use by runtime PM. This isn't directly harmful, but it is a bit wasteful, and also may induce unexpected suspend attempts (e.g., if a device was purposely last touched with pm_runtime_put_noidle()).
To avoid excess idle checks, only call pm_request_idle() on linked suppliers that opted into runtime PM.
Noticed by inspection of trace logs.
This is not expected to have a functional impact on systems that are using device links properly, and should only be considered an optimization.
--- drivers/base/power/runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +2 -1
@@ -349,7 +349,8 @@ static void rpm_suspend_suppliers(struct device *dev)list_for_each_entry_rcu (link, &dev->links.suppliers, c_node,device_links_read_lock_held ()) -pm_request_idle (link->supplier); +if (device_link_test (link,DL_FLAG_PM_RUNTIME )) +pm_request_idle (link->supplier);device_links_read_unlock (idx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 372/1756 ARM: dts: stm32: Drop bias-disable from STM32MP15xx DHCOM SoM sdmmc1_b4_pins_a
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 3572825773791f4258b553391f4e2187df321731 ]
Drop bias-disable property from STM32MP15xx DHCOM SoM sdmmc1_b4_pins_a to fix the following DT checker warning. The bias-pull-up property is the only bias-related property that has to be present in those pinctrl node subnodes.
"arch/arm/boot/dts/st/stm32mp153c-dhcom-drc02.dtb: pinctrl@50002000 (st,stm32mp157-pinctrl): sdmmc1-b4-0:pins1: {'pinmux': [10253, 10509, 10765, 11021, 12813], 'slew-rate': 1, 'drive-push-pull': True, 'bias-disable': True, 'bias-pull-up': True} is valid under each of {'required': ['bias-pull-up']}, {'required': ['bias-disable']} "
--- arch/arm/boot/dts/st/stm32mp15xx-dhcom-som.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/st/stm32mp15xx-dhcom-som.dtsi +2 -0
@@ -507,9 +507,11 @@ &sdmmc1_b4_pins_a { * - mandatory on SoMs without SD voltage translator */ pins1 { + /delete-property/ bias-disable; bias-pull-up; }; pins2 { + /delete-property/ bias-disable; bias-pull-up; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 373/1756 HID: i2c-hid: Unfollow the panel on shutdown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Yeh <[email protected]>
[ Upstream commit 59fc35a1edbfa5405122d749cf8843da131fd796 ]
i2c_hid_core_shutdown() sends SET_POWER(SLEEP) even for panel followers, but nothing in device_shutdown() guarantees whether the panel, and hence our own power, is still on by the time we get there.
Do what i2c_hid_core_remove() does and just unfollow the panel. drm_panel_remove_follower() calls panel_unpreparing() only while the panel is still prepared, which powers us down properly; if it is already unprepared no transfer is attempted at all. On MT8196 the panel is unprepared long before us, so this also drops the ~2s i2c bus timeout from every reboot.
--- drivers/hid/i2c-hid/i2c-hid-core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid-core.c +10 -1
@@ -1333,7 +1333,16 @@ void i2c_hid_core_shutdown(struct i2c_client *client) {struct i2c_hid *ihid =i2c_get_clientdata (client); -i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP ); +/* +* Like in i2c_hid_core_remove(): if we're a follower, the act of +* unfollowing will cause us to be powered down. Otherwise we need to +* manually do it. +*/ +if (ihid->is_panel_follower) +drm_panel_remove_follower (&ihid->panel_follower); +else +i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP ); +free_irq (client->irq, ihid);i2c_hid_core_shutdown_tail (ihid);
Signature · 1 line
2.53.0
Re: [PATCH 6.12 0373/1756] HID: i2c-hid: Unfollow the panel on shutdown
Hi Greg/Sasha,
Quoted 38 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Yeh <[email protected]>
[ Upstream commit
59fc35a1edbfa5405122d749cf8843da131fd796]
i2c_hid_core_shutdown()sendsSET_POWER(SLEEP)even for panel followers, but nothing indevice_shutdown()guarantees whether the panel, and hence our own power, is still on by the time we get there.Do what
i2c_hid_core_remove()does and just unfollow the panel.drm_panel_remove_follower()callspanel_unpreparing()only while the panel is still prepared, which powers us down properly; if it is already unprepared no transfer is attempted at all. On MT8196 the panel is unprepared long before us, so this also drops the ~2s i2c bus timeout from every reboot.Fixes 96a37bfd232a ("HID: i2c-hid: Support being a panel follower")Suggested-by Douglas Anderson <[email protected]>Signed-off-by Justin Yeh <[email protected]>Reviewed-by Douglas Anderson <[email protected]>Signed-off-by Jiri Kosina <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/hid/i2c-hid/i2c-hid-core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/hid/i2c-hid/i2c-hid-core.c +0
-1@@ -1333,7 +1333,16 @@ void i2c_hid_core_shutdown(struct i2c_client *client) {struct i2c_hid *ihid =i2c_get_clientdata (client); -i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP );
drivers/hid/i2c-hid/i2c-hid-core.c void i2c_hid_core_shutdown(struct i2c_client *client) · line 1345
Quoted 10 lines
drivers/hid/i2c-hid/i2c-hid-core.c +10
-0+/* +* Like in i2c_hid_core_remove(): if we're a follower, the act of +* unfollowing will cause us to be powered down. Otherwise we need to +* manually do it. +*/ +if (ihid->is_panel_follower) +drm_panel_remove_follower (&ihid->panel_follower); +else +i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP ); +
Verdict: We need to queue a followup fix, nothing to drop for now.
I ran an AI-assisted backport review of 6.12.y, and the report looks correct to me.
With fw_devlink=off, the new i2c-hid shutdown follower removal can dereference a panel freed by an earlier panel-driver unbind.
drivers/gpu/drm/drm_panel.c:
6.12.y 8b7bb3cf6ab7:
get_device(panel->dev);
follower->panel = panel;Original upstream 59fc35a1edbf:
list_for_each_entry(panel, &panel_list, list) {
if (dev_fwnode(panel->dev) == fwnode) {
drm_panel_get(panel);
mutex_unlock(&panel_lock);
return panel;drivers/gpu/drm/panel/panel-edp.c:
6.12.y 8b7bb3cf6ab7:
panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
if (!panel)
return -ENOMEM;Original upstream 59fc35a1edbf:
panel = devm_drm_panel_alloc(dev, struct panel_edp, base,
&panel_edp_funcs, DRM_MODE_CONNECTOR_eDP);
if (IS_ERR(panel))
return PTR_ERR(panel);With fw_devlink=off, panel unbind can leave the HID follower bound. get_device() does not retain its driver-managed panel allocation, so the new shutdown removal can use freed memory.
Upstream uses counted panel references and refcounted panel-edp allocation; the relevant follower change is ac3baea883da ("drm/panel:find_panel_by_fwnode() return a counted reference").
Nothing to do for this backport, we need to followup with a fix I think, this backport only exposes an existing issue with new shutdown path.
Thanks,
Harshit
Quoted 3 lines
drivers/hid/i2c-hid/i2c-hid-core.c +0
-0free_irq (client->irq, ihid);i2c_hid_core_shutdown_tail (ihid);
Sasha Levin
maintainerRe: [PATCH 6.12 0373/1756] HID: i2c-hid: Unfollow the panel on shutdown
Quoted 2 lines
Nothing to do for this backport, we need to followup with a fix I think, this backport only exposes an existing issue with new shutdown path.
We can keep it. ac3baea883da ("drm/panel: find_panel_by_fwnode() return a counted reference") can't go to 6.12 or 6.6 without the panel refcount infrastructure, and the same exposure already exists through i2c_hid_core_remove().
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 374/1756 bpf: Fix program BTF use-after-free in sleepable programs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit 88c9c6d0a766dd146545990053e8a04422ccb367 ]
Object kfunc calls embed metadata owned by the program BTF. A sleepable program can remain active under Tasks Trace RCU after its last reference is dropped, while program teardown releases the BTF through ordinary RCU. The invocation can then dereference freed metadata in bpf_obj_new().
Move btf_put() into __bpf_prog_put_rcu(), the callback that frees the program. When teardown is deferred, that callback runs after the program's own grace period (Tasks Trace RCU for sleepable programs and ordinary RCU otherwise), so the BTF outlives every active invocation. The non-deferred path invokes the callback synchronously, so load-error cleanup stays direct.
--- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/syscall.c +1 -1
@@ -2194,6 +2194,7 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu) { struct bpf_prog_aux *aux = container_of(rcu, struct bpf_prog_aux, rcu); +btf_put (aux->btf);kvfree (aux->func_info);kfree (aux->func_info_aux);free_uid (aux->user);
@@ -2204,7 +2205,6 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu)static void __bpf_prog_put_noref (struct bpf_prog *prog,bool deferred) {bpf_prog_kallsyms_del_all (prog); -btf_put (prog->aux->btf);module_put (prog->aux->mod);kvfree (prog->aux->jited_linfo);kvfree (prog->aux->linfo);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 375/1756 ARM: dts: imx7-tqma7: correctly specify PMIC voltage constraints
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nora Schiffer <[email protected]>
[ Upstream commit f322f8f68c2c3291633ead663effa3b25c18f7b1 ]
regulator-(min|max)-microvolt refer to the supported voltages according to board design, not the possible range of the regulators themselves. Update the configuration for the TQMa7x's PMIC and also add a comment regarding the PMIC's VCC_SD switching feature.
--- arch/arm/boot/dts/nxp/imx/imx7-tqma7.dtsi | 40 +++++++++++++---------- 1 file changed, 23 insertions(+), 17 deletions(-)
arch/arm/boot/dts/nxp/imx/imx7-tqma7.dtsi +23 -17
@@ -46,8 +46,8 @@ pfuze3000: pmic@8 { regulators { sw1a_reg: sw1a { - regulator-min-microvolt = <700000>; - regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1225000>; regulator-boot-on; regulator-always-on; regulator-ramp-delay = <6250>;
@@ -55,34 +55,33 @@ sw1a_reg: sw1a { /* use sw1c_reg to align with pfuze100/pfuze200 */ sw1c_reg: sw1b { - regulator-min-microvolt = <700000>; - regulator-max-microvolt = <1475000>; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; regulator-boot-on; regulator-always-on; regulator-ramp-delay = <6250>; }; sw2_reg: sw2 { - regulator-min-microvolt = <1500000>; - regulator-max-microvolt = <1850000>; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; regulator-boot-on; regulator-always-on; }; sw3a_reg: sw3 { - regulator-min-microvolt = <900000>; - regulator-max-microvolt = <1650000>; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; regulator-boot-on; regulator-always-on; }; swbst_reg: swbst { - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5150000>; + /* Not connected and left unconfigured */ }; snvs_reg: vsnvs { - regulator-min-microvolt = <1000000>; + regulator-min-microvolt = <3000000>; regulator-max-microvolt = <3000000>; regulator-boot-on; regulator-always-on;
@@ -95,18 +94,25 @@ vref_reg: vrefddr { vgen1_reg: vldo1 { regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; + regulator-max-microvolt = <1800000>; regulator-always-on; }; vgen2_reg: vldo2 { - regulator-min-microvolt = <800000>; - regulator-max-microvolt = <1550000>; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; regulator-always-on; }; vgen3_reg: vccsd { - regulator-min-microvolt = <2850000>; + /* + * Specified values refer to 3.3V operation; voltage for 1.8V + * operation is derived from this. + * + * The base board should usually mux GPIO1_IO08 to SD1_VSELECT for + * automatic switching of SD card IO voltage. + */ + regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; };
@@ -118,13 +124,13 @@ vgen4_reg: v33 { }; vgen5_reg: vldo3 { - regulator-min-microvolt = <1800000>; + regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; }; vgen6_reg: vldo4 { - regulator-min-microvolt = <1800000>; + regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 376/1756 x86/svm: Avoid sign extension of SVM_EVTINJ_VALID in 64-bit expressions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaithanya Lagisetty <[email protected]>
[ Upstream commit c5991239b148d40d4981901968b3a6a838ff517b ]
SVM_EVTINJ_VALID is defined as (1 << 31), i.e. as an int with the sign bit set. Whenever it is used in a 64-bit expression the int is sign extended, so bits 63:32 end up set as well. Two 64-bit users are affected.
verify_exception_info() uses the macro as a mask against a 64-bit value when it sanity checks hypervisor supplied exception information:
u64 info = ghcb->save.sw_exit_info_2; ... if ((info & SVM_EVTINJ_VALID) &&
The mask is 0xffffffff80000000, so the check also passes when any bit of the error code in 63:32 is set while the valid bit itself is clear.
svm_vmgexit_inject_exception() builds the value that KVM hands to an SEV-ES guest in GHCB SW_EXITINFO2:
u64 data = SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_EXEPT | vector;
For vector == X86_TRAP_GP this yields 0xffffffff8000030d instead of 0x000000008000030d. The field uses the EVENTINJ format, which holds the error code in bits 63:32, so KVM asks the guest to inject #GP with an error code of 0xffffffff. Linux guests only consume the error code when SVM_EVTINJ_VALID_ERR is set, which it is not here, so they are not affected in practice, but the value KVM writes is not the one it intends.
Use BIT() instead, as is already done for most single bit definitions in this header. Every other user applies the macro to a u32, where the resulting bits are unchanged.
Opportunistically give SVM_EVTINJ_VALID_ERR the same treatment, there's zero reason to open code BIT().
--- arch/x86/include/asm/svm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/svm.h +2 -2
@@ -616,8 +616,8 @@ static inline void __unused_size_checks(void)#define SVM_EVTINJ_TYPE_EXEPT (3 << SVM_EVTINJ_TYPE_SHIFT)#define SVM_EVTINJ_TYPE_SOFT (4 << SVM_EVTINJ_TYPE_SHIFT) -#define SVM_EVTINJ_VALID (1 << 31) -#define SVM_EVTINJ_VALID_ERR (1 << 11) +#define SVM_EVTINJ_VALID BIT(31) +#define SVM_EVTINJ_VALID_ERR BIT(11)#define SVM_EXITINTINFO_VEC_MASK SVM_EVTINJ_VEC_MASK#define SVM_EXITINTINFO_TYPE_MASK SVM_EVTINJ_TYPE_MASK
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 377/1756 clk: mediatek: reset: Fix device registration kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8d5fa37307ac1f0612cf17ac0ccabcc258cc1526 ]
The comment for mtk_register_reset_controller_with_dev() names the older helper and documents np rather than dev. The new helper takes a struct device and obtains its device node internally.
Use the actual function and parameter names and clarify that failures return negative error codes.
--- drivers/clk/mediatek/reset.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/mediatek/reset.h +3 -3
@@ -60,11 +60,11 @@ struct mtk_clk_rst_data { };/** -* mtk_register_reset_controller - Register mediatek clock reset controller with device -* @np: Pointer to device. +* mtk_register_reset_controller_with_dev - Register a MediaTek reset controller +* @dev: Device used to manage the reset controller resources. * @desc: Constant pointer to description of clock reset. * -* Return: 0 on success and errorno otherwise. +* Return: 0 on success, negative errno otherwise. */ int mtk_register_reset_controller_with_dev (struct device *dev,const struct mtk_clk_rst_desc *desc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 378/1756 clk: rs9: Add clock index range check to rs9_of_clk_get()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit a2ef401bdfd19aa41d0e3e1b630a12fbc01ac184 ]
rs9_of_clk_get() does not validate the clock index in the passed DT clock specifier. If DT specifies an incorrect and out-of-range index, this will access memory beyond the end of the clk_dif[] array.
Fix by this adding a range check to rs9_of_clk_get().
--- drivers/clk/clk-renesas-pcie.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/clk-renesas-pcie.c +5 -0
@@ -277,6 +277,11 @@ rs9_of_clk_get(struct of_phandle_args *clkspec, void *data)struct rs9_driver_data *rs9 = data;unsigned int idx = clkspec->args[0 ]; +if (idx >= rs9->chip_info->num_clks) { +pr_err ("%s: Invalid clock index %u\n" , __func__, idx); +return ERR_PTR (-EINVAL ); + } +return rs9->clk_dif[idx]; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 379/1756 clk: s2mps11: Propagate OF provider registration failures
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 276741aac3b56ba50bef59715ba18ba3f0b953a2 ]
s2mps11_clk_probe() ignores of_clk_add_hw_provider() failures, stores driver data and returns success even though DT consumers cannot acquire the registered clocks.
Return the provider error through the existing lookup cleanup path. Skip empty lookup slots while unwinding because S2MPS14 omits its CP clock.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/clk/clk-s2mps11.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/clk/clk-s2mps11.c +8 -4
@@ -188,8 +188,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev) clk_data->hws[i] = &s2mps11_clks[i].hw; } -of_clk_add_hw_provider (s2mps11_clks->clk_np, of_clk_hw_onecell_get, - clk_data); + ret =of_clk_add_hw_provider (s2mps11_clks->clk_np, + of_clk_hw_onecell_get, clk_data); +if (ret) + goto err_reg;platform_set_drvdata (pdev, s2mps11_clks);
@@ -197,8 +199,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev) err_reg:of_node_put (s2mps11_clks[0 ].clk_np); -while (--i >=0 ) -clkdev_drop (s2mps11_clks[i].lookup); +while (--i >=0 ) { +if (s2mps11_clks[i].lookup) +clkdev_drop (s2mps11_clks[i].lookup); + }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 380/1756 spi: Fix the return value in spi_new_ancillary_device() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 3742867ce96539100ed5f4c754f04273d8aa00d7 ]
spi_new_ancillary_device() returns the new struct spi_device, or an ERR_PTR() on failure, but its kernel-doc says "0 on success; negative errno on failure", which was never true. Describe the pointer.
--- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
@@ -2577,7 +2577,7 @@ static void of_register_spi_devices(struct spi_controller *ctlr) { }* * This may only be called from main SPI device's probe routine. * -* Return: 0 on success; negative errno on failure +* Return: the new device on success; an ERR_PTR() on failure */ struct spi_device *spi_new_ancillary_device (struct spi_device *spi,u8 chip_select)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 381/1756 ata: libata-scsi: Fix ata_scsi_hotplug() reference in kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 5915ab523e33057224a0240e27b88c6c2798b919 ]
The ata_scsi_remove_dev() comment misspells its caller as ata_eh_scsi_hotplug(). The caller is ata_scsi_hotplug(). Correct the reference, which predates libata's move from drivers/scsi to drivers/ata.
--- drivers/ata/libata-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-scsi.c +1 -1
@@ -4932,7 +4932,7 @@ int ata_scsi_offline_dev(struct ata_device *dev)* ata_scsi_remove_dev - remove attached SCSI device * @dev: ATA device to remove attached SCSI device for * -* This function is called from ata_eh_scsi_hotplug() and +* This function is called from ata_scsi_hotplug() and * responsible for removing the SCSI device attached to @dev. * * LOCKING:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 382/1756 gfs2: Fix the return value in gfs2_get_link() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 700a0a6892f7c0c541d5d23837cfab98cc744d17 ]
gfs2_get_link() returns the link target or an error pointer, but its kernel-doc still describes an integer status. The mismatch dates back to when gfs2_readlink() was replaced by generic_readlink() and persisted across the removal of nd_set_link().
Describe the returned pointer and error value.
--- fs/gfs2/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/inode.c +1 -1
@@ -1907,7 +1907,7 @@ static int gfs2_rename2(struct mnt_idmap *idmap, struct inode *odir,* * This can handle symlinks of any size. * -* Returns: 0 on success or error code +* Returns: the link target on success, an ERR_PTR() on failure */ static const char *gfs2_get_link(struct dentry *dentry,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 383/1756 virtio: synchronize callbacks after device reset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <[email protected]>
[ Upstream commit dd75508e6fe77116589c49658d0d18897688dc0b ]
virtio_reset_device says:
Note: this guarantees that vq callbacks are not in progress
but in practice, only virtio pci correctly synchronizes the cbs.
On other transports, a callback that is already executing, keeps running while the driver tears down the state it uses.
Add virtio_synchronize_cbs to virtio_reset_device fixing this for all transports that correctly implement synchronize_cbs().
Message-ID: <8ae2995ee649adcfe1398f7f1c4fc9f7028c3db1.1789204858.git.mst@redhat.com>
--- drivers/virtio/virtio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio.c +2 -0
@@ -264,6 +264,8 @@ void virtio_reset_device(struct virtio_device *dev)#endif dev->config->reset (dev); +/* Flush pending VQ/configuration callbacks. */ +virtio_synchronize_cbs (dev); }EXPORT_SYMBOL_GPL (virtio_reset_device);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 384/1756 virtio_pci_modern: move avq cleanup from reset to del_vqs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <[email protected]>
[ Upstream commit 2a12d96dd863cb23eadf07d8845e961580b5fcdf ]
vp_modern_avq_cleanup() detaches unused buffers from the admin virtqueue. Calling it from vp_reset() is incorrect:virtqueue_get_buf in the avq interrupt handler can race with virtqueue_detach_unused_buf in cleanup, and get_buf after detach is not documented as valid.
The root cause is that detaching buffers does not belong in reset at all - reset quiesces the device, while cleanup belongs where the virtqueue is about to be destroyed, from del_vqs.
Message-ID: <21fe35ad7b66e2c30dbdba6fe4df4824d1c0db66.1789204858.git.mst@redhat.com>
--- drivers/virtio/virtio_pci_modern.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/virtio/virtio_pci_modern.c +8 -4
@@ -245,6 +245,12 @@ static void vp_modern_avq_cleanup(struct virtio_device *vdev) } } +static void vp_modern_del_vqs (struct virtio_device *vdev) +{ +vp_modern_avq_cleanup (vdev); +vp_del_vqs (vdev); +} +static void vp_transport_features (struct virtio_device *vdev,u64 features) {struct virtio_pci_device *vp_dev =to_vp_device (vdev);
@@ -439,8 +445,6 @@ static void vp_reset(struct virtio_device *vdev)while (vp_modern_get_status (mdev))msleep (1 ); -vp_modern_avq_cleanup (vdev); -/* Flush pending VQ/configuration callbacks. */ vp_synchronize_vectors (vdev); }
@@ -766,7 +770,7 @@ static const struct virtio_config_ops virtio_pci_config_nodev_ops = { .set_status = vp_set_status, .reset = vp_reset, .find_vqs = vp_modern_find_vqs, - .del_vqs = vp_del_vqs, + .del_vqs = vp_modern_del_vqs, .synchronize_cbs = vp_synchronize_vectors, .get_features = vp_get_features, .finalize_features = vp_finalize_features,
@@ -786,7 +790,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = { .set_status = vp_set_status, .reset = vp_reset, .find_vqs = vp_modern_find_vqs, - .del_vqs = vp_del_vqs, + .del_vqs = vp_modern_del_vqs, .synchronize_cbs = vp_synchronize_vectors, .get_features = vp_get_features, .finalize_features = vp_finalize_features,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 385/1756 ALSA: control: Fix virtual master creation reference in kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit a347cc458d97ecd8adb5462b91559682a70aced6 ]
The snd_ctl_add_follower() comment refers to snd_ctl_create_virtual_master(), but virtual master controls are created with snd_ctl_make_virtual_master(). Correct the helper name.
--- include/sound/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sound/control.h +1 -1
@@ -241,7 +241,7 @@ int _snd_ctl_add_follower(struct snd_kcontrol *master,* @follower: follower element to add * * Add a virtual follower control to the given master element created via -* snd_ctl_create_virtual_master() beforehand. +* snd_ctl_make_virtual_master() beforehand. * * All followers must be the same type (returning the same information * via info callback). The function doesn't check it, so it's your
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 386/1756 ACPI: fan: Fix memory leak due to leftover devm_kcalloc() argument
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 2cf65d00347005eccf9a24801783377d7f920021 ]
An ACPI device object's dev field in passed as the first argument to devm_kcalloc() in acpi_fan_get_fps() which is incorrect and leads to a memory leak on driver probe errors and removal because the driver is not bound to that ACPI device.
Address this by replacing that pointer with a pointer to the device the driver is actually bound to.
While at it, drop a redundant error message after a memory allocation failure (that also gets printed relative to the ACPI device).
--- drivers/acpi/fan_core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/acpi/fan_core.c +3 -6
@@ -271,7 +271,7 @@ static int acpi_fan_speed_cmp(const void *a, const void *b)return fps1->speed - fps2->speed; } -static int acpi_fan_get_fps (struct acpi_device *device) +static int acpi_fan_get_fps (struct device *dev,struct acpi_device *device) {struct acpi_fan *fan =acpi_driver_data (device);struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL };
@@ -291,11 +291,8 @@ static int acpi_fan_get_fps(struct acpi_device *device) } fan->fps_count = obj->package.count -1 ;/* minus revision field */ - fan->fps =devm_kcalloc (&device->dev, - fan->fps_count,sizeof (struct acpi_fan_fps ), -GFP_KERNEL ); + fan->fps =devm_kcalloc (dev, fan->fps_count,sizeof (*fan->fps),GFP_KERNEL );if (!fan->fps) { -dev_err (&device->dev,"Not enough memory\n" ); status = -ENOMEM ; goto err; }
@@ -351,7 +348,7 @@ static int acpi_fan_probe(struct platform_device *pdev)if (result)return result; - result =acpi_fan_get_fps (device); + result =acpi_fan_get_fps (&pdev->dev, device);if (result)return result; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 387/1756 ACPI: video: Fix backlight unregistration ordering
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 46577d36611953d1b99e86493289cfc824116ad2 ]
In acpi_video_dev_unregister_backlight(), the sysfs interface of the cooling class device may access the brightness object under the backlight device's ACPI companion, so that object cannot be freed before unregistering the cooling class device.
Adjust the code to take that into account.
--- drivers/acpi/acpi_video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/acpi/acpi_video.c +6 -6
@@ -1828,6 +1828,12 @@ static int acpi_video_bus_register_backlight(struct acpi_video_bus *video)static void acpi_video_dev_unregister_backlight (struct acpi_video_device *device) { +if (device->cooling_dev) { +sysfs_remove_link (&device->dev->dev.kobj,"thermal_cooling" ); +sysfs_remove_link (&device->cooling_dev->device.kobj,"device" ); +thermal_cooling_device_unregister (device->cooling_dev); + device->cooling_dev =NULL ; + }if (device->backlight) {backlight_device_unregister (device->backlight); device->backlight =NULL ;
@@ -1837,12 +1843,6 @@ static void acpi_video_dev_unregister_backlight(struct acpi_video_device *devicekfree (device->brightness); device->brightness =NULL ; } -if (device->cooling_dev) { -sysfs_remove_link (&device->dev->dev.kobj,"thermal_cooling" ); -sysfs_remove_link (&device->cooling_dev->device.kobj,"device" ); -thermal_cooling_device_unregister (device->cooling_dev); - device->cooling_dev =NULL ; - } }static int acpi_video_bus_unregister_backlight (struct acpi_video_bus *video)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 388/1756 perf header: Fix potential memory corruption in cpu_cache_level__read
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit d964ffba01f5d0935dd6bc850029958a62c74491 ]
strim() may advance the pointer assigned to cache->size which causes later frees to crash.
Fix by performing the strim and then memmove-ing the potentially shifted string back over the original string.
The bug was introduced by the transition from rtrim() to strim(), as rtrim() wouldn't move on the left.
--- tools/perf/util/header.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
tools/perf/util/header.c +15 -3
@@ -1182,7 +1182,11 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 levreturn -1 ; cache->type[len] =0 ; - cache->type =strim (cache->type); + { +char *trimmed =strim (cache->type); + +memmove (cache->type, trimmed,strlen (trimmed) +1 ); + }scnprintf (file,PATH_MAX ,"%s/size" , path);if (sysfs__read_str (file, &cache->size, &len)) {
@@ -1191,7 +1195,11 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev } cache->size[len] =0 ; - cache->size =strim (cache->size); + { +char *trimmed =strim (cache->size); + +memmove (cache->size, trimmed,strlen (trimmed) +1 ); + }scnprintf (file,PATH_MAX ,"%s/shared_cpu_list" , path);if (sysfs__read_str (file, &cache->map, &len)) {
@@ -1201,7 +1209,11 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev } cache->map[len] =0 ; - cache->map =strim (cache->map); + { +char *trimmed =strim (cache->map); + +memmove (cache->map, trimmed,strlen (trimmed) +1 ); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 389/1756 regulator: qcom-rpmh: Fix the return value in rpmh_regulator_vrm_get_optimum_mode() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 51d6888b51e0c962250311b2cbfe5666da31dc0e ]
rpmh_regulator_vrm_get_optimum_mode() returns REGULATOR_MODE_NORMAL or REGULATOR_MODE_IDLE and cannot fail, but its kernel-doc says "0 on success, or a negative error number on failure", which was never true. Describe the mode.
--- drivers/regulator/qcom-rpmh-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/qcom-rpmh-regulator.c +1 -1
@@ -319,7 +319,7 @@ static unsigned int rpmh_regulator_vrm_get_mode(struct regulator_dev *rdev)* This function is used in the regulator_ops for VRM type RPMh regulator * devices. * -* Return: 0 on success, or a negative error number on failure +* Return: the regulator mode to use for the load */ static unsigned int rpmh_regulator_vrm_get_optimum_mode (struct regulator_dev *rdev,int input_uV,int output_uV,int load_uA)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 390/1756 libbpf: Support opening bpf objects of either endianness
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit bcc60abd67c7741a065480df4875534f62f758b1 ]
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Loading BPF objects of non-native byte-order is still disallowed however.
Stable-dep-of: e18e82ba9ed5 ("libbpf: fix log level propagation for light skeleton loaders")
--- tools/lib/bpf/libbpf.c | 51 +++++++++++++++++++++++++++------ tools/lib/bpf/libbpf_internal.h | 10 +++++++ 2 files changed, 52 insertions(+), 9 deletions(-)
tools/lib/bpf/libbpf.c +42 -9
@@ -696,6 +696,8 @@ struct bpf_object {/* Information when doing ELF related work. Only valid if efile.elf is not NULL */ struct elf_state efile; +unsigned char byteorder; +struct btf *btf;struct btf_ext *btf_ext;
@@ -942,6 +944,20 @@ bpf_object__add_programs(struct bpf_object *obj, Elf_Data *sec_data,return 0 ; } +static void bpf_object_bswap_progs (struct bpf_object *obj) +{ +struct bpf_program *prog = obj->programs; +struct bpf_insn *insn; +int p, i; + +for (p =0 ; p < obj->nr_programs; p++, prog++) { + insn = prog->insns; +for (i =0 ; i < prog->insns_cnt; i++, insn++) +bpf_insn_bswap (insn); + } +pr_debug ("converted %zu BPF programs to native byte order\n" , obj->nr_programs); +} +static const struct btf_member *find_member_by_offset (const struct btf_type *t,__u32 bit_offset) {
@@ -1507,6 +1523,7 @@ static void bpf_object__elf_finish(struct bpf_object *obj)elf_end (obj->efile.elf); obj->efile.elf =NULL ; + obj->efile.ehdr =NULL ; obj->efile.symbols =NULL ; obj->efile.arena_data =NULL ;
@@ -1572,6 +1589,16 @@ static int bpf_object__elf_init(struct bpf_object *obj) goto errout; } +/* Validate ELF object endianness... */ +if (ehdr->e_ident[EI_DATA ] !=ELFDATA2LSB && + ehdr->e_ident[EI_DATA ] !=ELFDATA2MSB ) { + err = -LIBBPF_ERRNO__ENDIAN ; +pr_warn ("elf: '%s' has unknown byte order\n" , obj->path); + goto errout; + } +/* and save after bpf_object_open() frees ELF data */ + obj->byteorder = ehdr->e_ident[EI_DATA ]; +if (elf_getshdrstrndx (elf, &obj->efile.shstrndx)) {pr_warn ("elf: failed to get section names section index for %s: %s\n" , obj->path,elf_errmsg (-1 ));
@@ -1600,19 +1627,15 @@ static int bpf_object__elf_init(struct bpf_object *obj)return err; } -static int bpf_object__check_endianness (struct bpf_object *obj) +static bool is_native_endianness (struct bpf_object *obj) {#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -if (obj->efile.ehdr->e_ident[EI_DATA ] ==ELFDATA2LSB ) -return 0 ; +return obj->byteorder ==ELFDATA2LSB ;#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -if (obj->efile.ehdr->e_ident[EI_DATA ] ==ELFDATA2MSB ) -return 0 ; +return obj->byteorder ==ELFDATA2MSB ;#else # error "Unrecognized __BYTE_ORDER__"#endif -pr_warn ("elf: endianness mismatch in %s.\n" , obj->path); -return -LIBBPF_ERRNO__ENDIAN ; } static int
@@ -3954,6 +3977,10 @@ static int bpf_object__elf_collect(struct bpf_object *obj)return -LIBBPF_ERRNO__FORMAT ; } +/* change BPF program insns to native endianness for introspection */ +if (!is_native_endianness (obj)) +bpf_object_bswap_progs (obj); +/* sort BPF programs by section name and in-section instruction offset * for faster search */
@@ -8054,7 +8081,6 @@ static struct bpf_object *bpf_object_open(const char *path, const void *obj_buf, } err =bpf_object__elf_init (obj); - err = err ? :bpf_object__check_endianness (obj); err = err ? :bpf_object__elf_collect (obj); err = err ? :bpf_object__collect_externs (obj); err = err ? :bpf_object_fixup_btf (obj);
@@ -8560,8 +8586,15 @@ static int bpf_object_load(struct bpf_object *obj, int extra_log_level, const chreturn libbpf_err (-EINVAL ); } -if (obj->gen_loader) +/* Disallow kernel loading programs of non-native endianness but +* permit cross-endian creation of "light skeleton". +*/ +if (obj->gen_loader) {bpf_gen__init (obj->gen_loader, extra_log_level, obj->nr_programs, obj->nr_maps); + }else if (!is_native_endianness (obj)) { +pr_warn ("object '%s': loading non-native endianness is unsupported\n" , obj->name); +return libbpf_err (-LIBBPF_ERRNO__ENDIAN ); + } err =bpf_object_prepare_token (obj); err = err ? :bpf_object__probe_loading (obj);
tools/lib/bpf/libbpf_internal.h +10 -0
@@ -617,6 +617,16 @@ static inline bool is_ldimm64_insn(struct bpf_insn *insn)return insn->code == (BPF_LD |BPF_IMM |BPF_DW ); } +static inline void bpf_insn_bswap (struct bpf_insn *insn) +{ +__u8 tmp_reg = insn->dst_reg; + + insn->dst_reg = insn->src_reg; + insn->src_reg = tmp_reg; + insn->off =bswap_16 (insn->off); + insn->imm =bswap_32 (insn->imm); +} +/* Unconditionally dup FD, ensuring it doesn't use [0, 2] range. * Original FD is not closed or altered in any other way. * Preserves original FD value, if it's invalid (negative).
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/1756 libbpf: fix log level propagation for light skeleton loaders
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahe Tardy <[email protected]>
[ Upstream commit e18e82ba9ed53f60acce5f9995ee357a9f7ab91d ]
bpftool's -d option is documented to enable bpf_trace_printk() messages from the generated syscall loader when used with -L as specified in commit d510296d331a ("bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.")
However commit b59e4ce8bcaa ("bpftool: Switch bpf_object__load_xattr() to bpf_object__load()") changed bpftool to use bpf_object__load() which call the internal bpf_object_load with extra_log_level to 0 instead of bpf_object__load_xattr with the user request log_level.
All the plumbing was still there to generate the bpf_trace_printk() instructions from the generator but was now unreachable because bpf_gen__init() was called with extra_log_level to 0, leaving gen->log_level at 0.
This uses the obj->log_level field introduced in commit e0e3ea888c69 ("libbpf: Allow passing user log setting through bpf_object_open_opts") set from reading verifier_logs in do_skeleton(). This preserves both object-level and explicit load-time logging settings.
--- tools/lib/bpf/libbpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +2 -1
@@ -8590,7 +8590,8 @@ static int bpf_object_load(struct bpf_object *obj, int extra_log_level, const ch* permit cross-endian creation of "light skeleton". */ if (obj->gen_loader) { -bpf_gen__init (obj->gen_loader, extra_log_level, obj->nr_programs, obj->nr_maps); +bpf_gen__init (obj->gen_loader, obj->log_level | extra_log_level, + obj->nr_programs, obj->nr_maps); }else if (!is_native_endianness (obj)) {pr_warn ("object '%s': loading non-native endianness is unsupported\n" , obj->name);return libbpf_err (-LIBBPF_ERRNO__ENDIAN );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/1756 fs/ntfs3: take run_lock when freeing offs_folio in ni_decompress_file
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit ad39d8d90fa0fd99b2714d4c84c6f4e1c399f1f4 ]
attr_wof_frame_info() allocates, caches and dereferences ni->file.offs_folio under down_write(&ni->file.run_lock). ni_decompress_file() frees the same folio with folio_put() without taking run_lock. When a WOF externally-compressed file is opened for write, ni_decompress_file() can drop the last reference while a concurrent O_RDONLY reader is dereferencing the folio in attr_wof_frame_info(), leading to a use-after-free:
BUG: KASAN: use-after-free in attr_wof_frame_info (fs/ntfs3/attrib.c:1619) Read of size 4 at addr ffff8880120c9000 by task exploit Call Trace: attr_wof_frame_info (fs/ntfs3/attrib.c:1619) ni_read_frame (fs/ntfs3/frecord.c:2421) ni_read_folio_cmpr (fs/ntfs3/frecord.c:1916) ntfs_read_folio (fs/ntfs3/inode.c:648) read_pages (mm/readahead.c:181) page_cache_ra_unbounded (mm/readahead.c:292) force_page_cache_ra (mm/readahead.c:364) page_cache_sync_ra (mm/readahead.c:573) filemap_get_pages (mm/filemap.c:2688) filemap_read (mm/filemap.c:2806) generic_file_read_iter (mm/filemap.c:2994) ntfs_file_read_iter (fs/ntfs3/file.c:842) vfs_read (fs/read_write.c:574) __x64_sys_pread64 (fs/read_write.c:773)
Take run_lock around the folio_put(), as is done for every other access to ni->file.offs_folio.
--- fs/ntfs3/frecord.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/frecord.c +3 -0
@@ -2395,10 +2395,13 @@ int ni_decompress_file(struct ntfs_inode *ni)/* Clear cached flag. */ ni->ni_flags &= ~NI_FLAG_COMPRESSED_MASK ; +/* offs_folio is accessed under run_lock in attr_wof_frame_info(). */ +down_write (&ni->file.run_lock);if (ni->file.offs_folio) {folio_put (ni->file.offs_folio); ni->file.offs_folio =NULL ; } +up_write (&ni->file.run_lock); mapping->a_ops = &ntfs_aops; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/1756 fs/ntfs3: update ctime only on successful setxattr
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baolin Liu <[email protected]>
[ Upstream commit bfa6296bb6a0e2333796a9507beb4605b92a9fdf ]
ntfs_setxattr() updates ctime and marks the inode dirty even when the xattr operation fails.
Do that only on success.
--- fs/ntfs3/xattr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ntfs3/xattr.c +4 -2
@@ -958,8 +958,10 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler, NULL); out: -inode_set_ctime_current (inode); -mark_inode_dirty (inode); +if (!err) { +inode_set_ctime_current (inode); +mark_inode_dirty (inode); + }return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/1756 ntfs: Do not kmap page cache pages for compression
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 953b79a7a124c3dae86544cea581a5bc7655aa13 ]
These pages are accessed through vmap; they are not accessed by calling page_address(), so they do not need to be kmapped.
Stable-dep-of: a32e893a077a ("fs/ntfs3: zero frame pages on read error")
--- fs/ntfs3/frecord.c | 11 ----------- 1 file changed, 11 deletions(-)
fs/ntfs3/frecord.c +0 -11
@@ -2504,9 +2504,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,* To simplify decompress algorithm do vmap for source * and target pages. */ -for (i =0 ; i < pages_per_frame; i++) -kmap (pages[i]); - frame_size = pages_per_frame <<PAGE_SHIFT ; frame_mem =vmap (pages, pages_per_frame,VM_MAP ,PAGE_KERNEL );if (!frame_mem) {
@@ -2763,7 +2760,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, out:for (i =0 ; i < pages_per_frame; i++) { pg = pages[i]; -kunmap (pg);SetPageUptodate (pg); }
@@ -2850,9 +2846,6 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages, goto out1; } -for (i =0 ; i < pages_per_frame; i++) -kmap (pages[i]); -/* Map in-memory frame for read-only. */ frame_mem =vmap (pages, pages_per_frame,VM_MAP ,PAGE_KERNEL_RO );if (!frame_mem) {
@@ -2918,11 +2911,7 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages, out3:vunmap (frame_mem); - out2: -for (i =0 ; i < pages_per_frame; i++) -kunmap (pages[i]); -vunmap (frame_ondisk); out1:for (i =0 ; i < pages_per_frame; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/1756 fs/ntfs3: zero frame pages on read error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit a32e893a077a4b0d3b04c86cb7f69e354a187995 ]
ni_read_frame() marks every frame page uptodate at the 'out:' label regardless of the return value. The pages come from ntfs_lock_new_page() and are not zeroed, and several error paths reach 'out:' before anything is written to them (e.g. a failed decompress_lznt()/decompress_lzx_xpress() on a corrupted chunk, or an allocation failure).
A page marked uptodate is served directly from the page cache, so a later read() of the file returns the uninitialized page contents to userspace. On a crafted compressed image this leaks kernel memory, including pointers.
Zero each page on the error path before marking it uptodate. The success path is unchanged.
--- fs/ntfs3/frecord.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ntfs3/frecord.c +2 -0
@@ -2760,6 +2760,8 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, out:for (i =0 ; i < pages_per_frame; i++) { pg = pages[i]; +if (err) +clear_highpage (pg);SetPageUptodate (pg); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/1756 pinctrl: amd: Add PM debugging message for turning on/off wakes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello (AMD) <[email protected]>
[ Upstream commit 54b962fa14dc82a625436fcbcee7b3f2067a4f6d ]
The GPIOs for devices not in _AEI/_EVT such as touchpad or touchscreen won't have wakeup turned on until the suspend sequence starts.
Due to code in amd_gpio_suspend_hibernate_common() masking the interrupt can make this difficult to follow what's going on. Add an explicit debugging message to tell when that was turned on/off.
Stable-dep-of: 44c232e80adc ("pinctrl: amd: add timeout to irq-enable readback")
--- drivers/pinctrl/pinctrl-amd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pinctrl/pinctrl-amd.c +3 -0
@@ -440,6 +440,9 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)u32 wake_mask =BIT (WAKE_CNTRL_OFF_S0I3 ) |BIT (WAKE_CNTRL_OFF_S3 );int err; +pm_pr_dbg ("Setting wake for GPIO %lu to %s\n" , + d->hwirq,str_enable_disable (on)); +raw_spin_lock_irqsave (&gpio_dev->lock, flags); pin_reg =readl (gpio_dev->base + (d->hwirq)*4 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/1756 pinctrl: amd: Dont access irq_datas hwirq member directly
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello (AMD) <[email protected]>
[ Upstream commit 7a399ce67e981f5f28afc1ff50772acd1f4e7bbf ]
There is an irqd_to_hwirq() intended to get the hwirq number. Switch all use to it.
Stable-dep-of: 44c232e80adc ("pinctrl: amd: add timeout to irq-enable readback")
--- drivers/pinctrl/pinctrl-amd.c | 40 ++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-)
drivers/pinctrl/pinctrl-amd.c +23 -17
@@ -375,14 +375,15 @@ static void amd_gpio_irq_enable(struct irq_data *d)unsigned long flags;struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc); +irq_hw_number_t hwirq =irqd_to_hwirq (d); -gpiochip_enable_irq (gc, d->hwirq); +gpiochip_enable_irq (gc, hwirq);raw_spin_lock_irqsave (&gpio_dev->lock, flags); - pin_reg =readl (gpio_dev->base + (d->hwirq)*4 ); + pin_reg =readl (gpio_dev->base + hwirq *4 ); pin_reg |=BIT (INTERRUPT_ENABLE_OFF ); pin_reg |=BIT (INTERRUPT_MASK_OFF ); -writel (pin_reg, gpio_dev->base + (d->hwirq)*4 ); +writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); }
@@ -392,15 +393,16 @@ static void amd_gpio_irq_disable(struct irq_data *d)unsigned long flags;struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc); +irq_hw_number_t hwirq =irqd_to_hwirq (d);raw_spin_lock_irqsave (&gpio_dev->lock, flags); - pin_reg =readl (gpio_dev->base + (d->hwirq)*4 ); + pin_reg =readl (gpio_dev->base + hwirq *4 ); pin_reg &= ~BIT (INTERRUPT_ENABLE_OFF ); pin_reg &= ~BIT (INTERRUPT_MASK_OFF ); -writel (pin_reg, gpio_dev->base + (d->hwirq)*4 ); +writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); -gpiochip_disable_irq (gc, d->hwirq); +gpiochip_disable_irq (gc, hwirq); }static void amd_gpio_irq_mask (struct irq_data *d)
@@ -409,11 +411,12 @@ static void amd_gpio_irq_mask(struct irq_data *d)unsigned long flags;struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc); +irq_hw_number_t hwirq =irqd_to_hwirq (d);raw_spin_lock_irqsave (&gpio_dev->lock, flags); - pin_reg =readl (gpio_dev->base + (d->hwirq)*4 ); + pin_reg =readl (gpio_dev->base + hwirq *4 ); pin_reg &= ~BIT (INTERRUPT_MASK_OFF ); -writel (pin_reg, gpio_dev->base + (d->hwirq)*4 ); +writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); }
@@ -423,11 +426,12 @@ static void amd_gpio_irq_unmask(struct irq_data *d)unsigned long flags;struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc); +irq_hw_number_t hwirq =irqd_to_hwirq (d);raw_spin_lock_irqsave (&gpio_dev->lock, flags); - pin_reg =readl (gpio_dev->base + (d->hwirq)*4 ); + pin_reg =readl (gpio_dev->base + hwirq *4 ); pin_reg |=BIT (INTERRUPT_MASK_OFF ); -writel (pin_reg, gpio_dev->base + (d->hwirq)*4 ); +writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); }
@@ -438,20 +442,21 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc);u32 wake_mask =BIT (WAKE_CNTRL_OFF_S0I3 ) |BIT (WAKE_CNTRL_OFF_S3 ); +irq_hw_number_t hwirq =irqd_to_hwirq (d);int err;pm_pr_dbg ("Setting wake for GPIO %lu to %s\n" , - d->hwirq,str_enable_disable (on)); + hwirq,str_enable_disable (on));raw_spin_lock_irqsave (&gpio_dev->lock, flags); - pin_reg =readl (gpio_dev->base + (d->hwirq)*4 ); + pin_reg =readl (gpio_dev->base + hwirq *4 );if (on) pin_reg |= wake_mask;else pin_reg &= ~wake_mask; -writel (pin_reg, gpio_dev->base + (d->hwirq)*4 ); +writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags);if (on)
@@ -487,9 +492,10 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)unsigned long flags;struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc); +irq_hw_number_t hwirq =irqd_to_hwirq (d);raw_spin_lock_irqsave (&gpio_dev->lock, flags); - pin_reg =readl (gpio_dev->base + (d->hwirq)*4 ); + pin_reg =readl (gpio_dev->base + hwirq *4 );switch (type &IRQ_TYPE_SENSE_MASK ) {case IRQ_TYPE_EDGE_RISING :
@@ -555,10 +561,10 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg_irq_en = pin_reg; pin_reg_irq_en |= mask; pin_reg_irq_en &= ~BIT (INTERRUPT_MASK_OFF ); -writel (pin_reg_irq_en, gpio_dev->base + (d->hwirq)*4 ); -while ((readl (gpio_dev->base + (d->hwirq)*4 ) & mask) != mask) +writel (pin_reg_irq_en, gpio_dev->base + hwirq *4 ); +while ((readl (gpio_dev->base + hwirq *4 ) & mask) != mask)continue ; -writel (pin_reg, gpio_dev->base + (d->hwirq)*4 ); +writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/1756 pinctrl: amd: add timeout to irq-enable readback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 44c232e80adc26634e40b3dbeaa20711da9ecf0d ]
amd_gpio_irq_set_type() polls INTERRUPT_ENABLE with IRQs off and no timeout. Use readl_poll_timeout_atomic() and return -ETIMEDOUT.
--- drivers/pinctrl/pinctrl-amd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-amd.c +5 -3
@@ -18,6 +18,7 @@#include <linux/errno.h> #include <linux/log2.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/gpio/driver.h> #include <linux/slab.h> #include <linux/platform_device.h>
@@ -488,7 +489,7 @@ static void amd_gpio_irq_eoi(struct irq_data *d)static int amd_gpio_irq_set_type (struct irq_data *d,unsigned int type) {int ret =0 ; -u32 pin_reg, pin_reg_irq_en, mask; +u32 pin_reg, pin_reg_irq_en, mask, reg;unsigned long flags;struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct amd_gpio *gpio_dev =gpiochip_get_data (gc);
@@ -562,8 +563,9 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg_irq_en |= mask; pin_reg_irq_en &= ~BIT (INTERRUPT_MASK_OFF );writel (pin_reg_irq_en, gpio_dev->base + hwirq *4 ); -while ((readl (gpio_dev->base + hwirq *4 ) & mask) != mask) -continue ; +if (readl_poll_timeout_atomic (gpio_dev->base + hwirq *4 , reg, + (reg & mask) == mask,1 ,1000 )) + ret = -ETIMEDOUT ;writel (pin_reg, gpio_dev->base + hwirq *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/1756 microblaze: uaccess: Zero out destination on failed get_user()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 54c35131e628e1a18f02365495a24a73a1fb515e ]
On failure get_user() is supposed to zero out the destination variable. This is documented in the kdoc of the microblaze get_user() implementation and validated in lib/tests/usercopy_kunit.c.
Currently that zeroing is missing.
Add it.
--- arch/microblaze/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/microblaze/include/asm/uaccess.h +2 -1
@@ -95,7 +95,8 @@ extern long __user_bad(void);#define get_user (x, ptr) ({ \ const typeof(*(ptr)) __user *__gu_ptr = (ptr); \ access_ok(__gu_ptr, sizeof(*__gu_ptr)) ? \ - __get_user(x, __gu_ptr) : -EFAULT; \ + __get_user(x, __gu_ptr) : \ + ((x) = 0, -EFAULT); \ })#define __get_user (x, ptr) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/1756 microblaze: Pass -m{big,little}-endian through KBUILD_CPPFLAGS
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit b9eababe8c0b9f71ce7f35f903879a7fcb6daebe ]
These parameters are also necessary for preprocessed files which do not contain code. One example is arch/microblaze/kernel/vmlinux.lds.S which inspects __MICROBLAZEEL__ for the definition of 'jiffies_64'. As currently the endianness is not passed from the build system for this file, the preprocessor will instead use the default endianness of the toolchain. When a default big-endian toolchain is used to build a little-endian kernel, that kernel will hang during delay calibration as 'jiffies' never changes.
Make sure all preprocessor invocations know about the correct endianness by passing it through KBUILD_CPPFLAGS. This will also be inherited by CFLAGS and AFLAGS.
--- arch/microblaze/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/microblaze/Makefile +2 -4
@@ -34,12 +34,10 @@ CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare ifdef CONFIG_CPU_BIG_ENDIAN -KBUILD_CFLAGS += -mbig-endian -KBUILD_AFLAGS += -mbig-endian +KBUILD_CPPFLAGS += -mbig-endian KBUILD_LDFLAGS += -EB else -KBUILD_CFLAGS += -mlittle-endian -KBUILD_AFLAGS += -mlittle-endian +KBUILD_CPPFLAGS += -mlittle-endian KBUILD_LDFLAGS += -EL endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/1756 arm64: pi: Run the source checker on the libfdt objects under C=2
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 44b14ff4aebeae98663d0fd424b4ef88237ee981 ]
The custom lib-%.o rule reuses rule_cc_o_c, which hooks the source checker only for C=1, and that only when the object is rebuilt. The C=2 hook, cmd_force_checksrc, hangs off the standard %.o rule, so "make C=2" silently skips the two libfdt objects. Call cmd_force_checksrc after the compile rule, as the standard rule does.
--- arch/arm64/kernel/pi/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/pi/Makefile +1 -0
@@ -34,6 +34,7 @@ $(obj)/lib-%.pi.o: OBJCOPYFLAGS += --prefix-alloc-sections=.init $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE $(call if_changed_rule,cc_o_c) + $(call cmd,force_checksrc) obj-y := idreg-override.pi.o \ map_kernel.pi.o map_range.pi.o \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/1756 wifi: mac80211: Fix the return value in mesh_path_add() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 5c7b043cb1ef4bca9aa2e793dab862c0989d59c3 ]
mesh_path_add() has returned the new (or the already existing) struct mesh_path, or an ERR_PTR(), since commit ae76eef027f7 ("mac80211: return new mpath from mesh_path_add()"), but its kernel-doc still says "Returns: 0 on success". Describe the pointer.
--- net/mac80211/mesh_pathtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +1 -1
@@ -679,7 +679,7 @@ void mesh_fast_tx_flush_addr(struct ieee80211_sub_if_data *sdata,* @dst: destination address of the path (ETH_ALEN length) * @sdata: local subif * -* Returns: 0 on success +* Returns: the new or the existing path on success, an ERR_PTR() on failure * * State: the initial state of the new path is set to 0 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/1756 wifi: mac80211: dont reset the TXQ scheduling round number
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Bairaktaris <[email protected]>
[ Upstream commit 8ea81827d3537db7cfcc82c008f052bb1bbe7567 ]
A round is ended when ieee80211_next_txq() meets a txq whose remembered round number is the current one, meaning it has gone full circle.
When the AC exceeds the airtime limit, ieee80211_txq_schedule_start() sets the round number to 0 to close the round. The next open round is
1. A txq from an earlier round 1 still remembers the "1", so the next round stops on it and serves nothing.
Fix: use a separate open/closed flag and let the round number keep counting.
Testing: ~4200 skipped selections per 20s without the fix and 20 skipped selections per 20s with the fix on ath11k (with my AQL series applied) at BE 500/1000.
--- net/mac80211/ieee80211_i.h | 1 + net/mac80211/tx.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
@@ -1355,6 +1355,7 @@ struct ieee80211_local {spinlock_t active_txq_lock[IEEE80211_NUM_ACS ];struct list_head active_txqs[IEEE80211_NUM_ACS ];u16 schedule_round[IEEE80211_NUM_ACS ]; +bool schedule_open[IEEE80211_NUM_ACS ];/* serializes ieee80211_handle_wake_tx_queue */ spinlock_t handle_wake_tx_queue_lock;
net/mac80211/tx.c +4 -4
@@ -4166,7 +4166,7 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)spin_lock_bh (&local->active_txq_lock[ac]); -if (!local->schedule_round[ac]) +if (!local->schedule_open[ac]) goto out; begin:
@@ -4370,12 +4370,12 @@ void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac)spin_lock_bh (&local->active_txq_lock[ac]); -if (ieee80211_txq_schedule_airtime_check (local, ac)) { + local->schedule_open[ac] = +ieee80211_txq_schedule_airtime_check (local, ac); +if (local->schedule_open[ac]) { local->schedule_round[ac]++;if (!local->schedule_round[ac]) local->schedule_round[ac]++; - }else { - local->schedule_round[ac] =0 ; }spin_unlock_bh (&local->active_txq_lock[ac]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/1756 mtd: spi-nor: spansion: Remove s25fs256s0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takahiro Kuwano <[email protected]>
[ Upstream commit f917d9edf54c3dd578efc231b8fbcd35744f99cd ]
The Spansion ID table lists s25fs256s0 and s25fs256s1 as variants distinguished by id[4] (0x00 for 256 KB sectors and 0x01 for 64 KB sectors), following an incorrect statement in the datasheet.
The sector size of s25fs256s is configurable between 256 KB and 64 KB. The factory default is 64 KB, and id[4] is always 0x01 regardless of the configured sector size. Remove the invalid s25fs256s0 entry from the ID table.
--- drivers/mtd/spi-nor/spansion.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/mtd/spi-nor/spansion.c +0 -7
@@ -829,13 +829,6 @@ static const struct flash_info spansion_nor_parts[] = { .sector_size = SZ_256K, .no_sfdp_flags = SPI_NOR_SKIP_SFDP | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, .mfr_flags = USE_CLSR, - }, { - .id = SNOR_ID(0x01, 0x02, 0x19, 0x4d, 0x00, 0x81), - .name = "s25fs256s0", - .size = SZ_32M, - .sector_size = SZ_256K, - .no_sfdp_flags = SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, - .mfr_flags = USE_CLSR, }, { .id = SNOR_ID(0x01, 0x02, 0x19, 0x4d, 0x01, 0x80), .name = "s25fl256s1",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/1756 wifi: wfx: fix use-after-free of the cooling work on device removal
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérôme Pouiller <[email protected]>
[ Upstream commit 17402a869778f6c17b88fd360d7a96378779f97c ]
When the device reports that it is too hot, wfx_suspend_hot_dev() blocks the Tx queues and arms cooling_timeout_work with a 10s delay. If the device recovers a normal temperature before the delay expires, the work is canceled. Else, the work declares the chip frozen and unblocks the Tx queues.
However, this work is never canceled when the device is removed. cooling_timeout_work is queued on the system workqueue, while struct wfx_dev is released by wfx_free_common() (through ieee80211_free_hw()). So, if the device is unbound during this 10s window, the work fires after struct wfx_dev has been freed and dereferences it.
Cancel the work during the teardown. It has to be done after wfx_bh_unregister(): the "device too hot" indication is processed by the bh, so canceling the work earlier would allow the bh to rearm it. On the other hand, the work calls wfx_tx_unlock(), which may in turn call wfx_bh_request_tx(). So it has to be canceled before bh_wq is destroyed.
Note that the Tx queues are intentionally left blocked: the device is going away, so there is nothing to unblock.
The issue was reported by the Sashiko review bot and the fix has been written by Copilot (including the commit log). The use-case is difficult to reproduce, so this code has not been tested. However, I don't believe this patch could cause any regression.
--- drivers/net/wireless/silabs/wfx/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/silabs/wfx/main.c +2 -0
@@ -473,6 +473,7 @@ int wfx_probe(struct wfx_dev *wdev) wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv); bh_unregister:wfx_bh_unregister (wdev); +cancel_delayed_work_sync (&wdev->cooling_timeout_work);destroy_workqueue (wdev->bh_wq);return err; }
@@ -483,6 +484,7 @@ void wfx_release(struct wfx_dev *wdev)wfx_hif_shutdown (wdev); wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv);wfx_bh_unregister (wdev); +cancel_delayed_work_sync (&wdev->cooling_timeout_work);destroy_workqueue (wdev->bh_wq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/1756 f2fs: quota: fix stale lock holder on remount failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianan Huang <[email protected]>
[ Upstream commit 3f140a60c92a5e2e9885adac70cd3686ba4ee19a ]
F2FS remount can fail while duplicating a journalled quota file name.
f2fs_remount()
- sbi->umount_lock_holder = current
- kstrdup(F2FS_OPTION(sbi).s_qf_names[i])
: fails
- free previously duplicated names
- return -ENOMEM
The direct return leaves umount_lock_holder pointing at the failed remount context. A later checkpoint may then wrongly treat another context as the s_umount lock holder.
Add a restore_holder cleanup path and use it before returning -ENOMEM.
--- fs/f2fs/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/super.c +3 -1
@@ -2381,7 +2381,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)if (!org_mount_opt.s_qf_names[i]) {for (j =0 ; j < i; j++)kfree (org_mount_opt.s_qf_names[j]); -return -ENOMEM ; + err = -ENOMEM ; + goto restore_holder; } }else { org_mount_opt.s_qf_names[i] =NULL ;
@@ -2645,6 +2646,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) sbi->mount_opt = org_mount_opt; sb->s_flags = old_sb_flags; +restore_holder: sbi->umount_lock_holder =NULL ;return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/1756 firmware: imx: dsp: fix mailbox channel leak on kasprintf failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit e3631d0242842940f9e902afaea98202e56277e8 ]
If kasprintf() fails while setting up mailbox channels, already requested channels from earlier iterations were never freed. Route the failure through the existing cleanup path.
--- drivers/firmware/imx/imx-dsp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/firmware/imx/imx-dsp.c +4 -2
@@ -99,8 +99,10 @@ static int imx_dsp_setup_channels(struct imx_dsp_ipc *dsp_ipc)else chan_name =kasprintf (GFP_KERNEL ,"rxdb%d" , i -2 ); -if (!chan_name) -return -ENOMEM ; +if (!chan_name) { + ret = -ENOMEM ; + goto out; + } dsp_chan = &dsp_ipc->chans[i]; dsp_chan->name = chan_name;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/1756 phy: hisilicon: hi3670: Fix OF node and device reference leaks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 1499f3d3407f5310731bcdf324387c321258fd75 ]
hi3670_pcie_get_resources_from_pcie() leaks two references:
1) The OF node returned by of_get_child_by_name() is never released.
2) The device returned by bus_find_device_by_of_node() is never put.
Fix both leaks by calling of_node_put() right after bus_find_device_by_of_node(), and put_device() after dev_get_regmap() when the temporary pcie_dev reference is no longer needed.
--- drivers/phy/hisilicon/phy-hi3670-pcie.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/hisilicon/phy-hi3670-pcie.c +2 -0
@@ -565,6 +565,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy) } pcie_dev =bus_find_device_by_of_node (&platform_bus_type, pcie_port); +of_node_put (pcie_port);if (!pcie_dev) {dev_err (dev,"Didn't find pcie device\n" );return -ENODEV ;
@@ -579,6 +580,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy)* right regmap. So, let's use the named version. */ phy->apb =dev_get_regmap (pcie_dev,"kirin_pcie_apb" ); +put_device (pcie_dev);if (!phy->apb) {dev_err (dev,"Failed to get APB regmap\n" );return -ENODEV ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/1756 phy: cadence: Sierra: Do not modify register when getting parent clock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory CLEMENT <[email protected]>
[ Upstream commit 955e68eb3067842067b7b5395a3f8c278428802a ]
The get_parent() callback for the PLL_CMNLC1 clock was incorrectly writing to the register while determining the parent clock index. This unintended register access forces the PHY back into training mode. If the PHY is already configured, this unexpected change prevents it from exiting training mode.
Remove the register write operation to ensure the PHY remains stable during the get_parent() callback.
--- drivers/phy/cadence/phy-cadence-sierra.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/phy/cadence/phy-cadence-sierra.c +2 -9
@@ -695,23 +695,16 @@ static const struct phy_ops noop_ops = {static u8 cdns_sierra_pll_mux_get_parent (struct clk_hw *hw) {struct cdns_sierra_pll_mux *mux =to_cdns_sierra_pll_mux (hw); -struct regmap_field *plllc1en_field = mux->plllc1en_field; -struct regmap_field *termen_field = mux->termen_field;struct regmap_field *field = mux->pfdclk_sel_preg;unsigned int val;int index;regmap_field_read (field, &val); -if (strstr (clk_hw_get_name (hw), clk_names[CDNS_SIERRA_PLL_CMNLC1 ])) { +if (strstr (clk_hw_get_name (hw), clk_names[CDNS_SIERRA_PLL_CMNLC1 ])) index =clk_mux_val_to_index (hw, cdns_sierra_pll_mux_table[CMN_PLLLC1 ],0 , val); -if (index ==1 ) { -regmap_field_write (plllc1en_field,1 ); -regmap_field_write (termen_field,1 ); - } - }else { +else index =clk_mux_val_to_index (hw, cdns_sierra_pll_mux_table[CMN_PLLLC ],0 , val); - }return index; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/1756 memory: emif: fix device_node reference leak on np_ddr
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miles Krause <[email protected]>
[ Upstream commit 314ef67d673284d4c070455bd62d332f6d0f8634 ]
of_get_memory_device_details() takes a reference on the DDR device node via of_parse_phandle() and stores it in emif->np_ddr for later use, but drops that reference without calling of_node_put() on two error paths: the devm_kzalloc() allocation-failure check and the is_dev_data_valid() check. Both return NULL immediately, leaking the node reference each time either failure triggers.
The same reference is also never released on the success path: it is kept for the life of the bound device (compared against a later instance's np_ddr in the duplicate-DDR-geometry check) but emif_remove() never calls of_node_put() on it, leaking it every time an EMIF device unbinds. of_node_put() on a NULL pointer is a no-op, so this is also safe for the non-DT get_device_details() path, where np_ddr is left NULL by devm_kzalloc().
--- drivers/memory/emif.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/memory/emif.c +3 -0
@@ -921,6 +921,7 @@ static struct emif_data *of_get_memory_device_details(if (!emif || !pd || !dev_info) {dev_err (dev,"%s: Out of memory!!\n" , __func__); +of_node_put (np_ddr); goto error; }
@@ -945,6 +946,7 @@ static struct emif_data *of_get_memory_device_details( pd->device_info->io_width, pd->phy_type, pd->ip_rev, emif->dev)) {dev_err (dev,"%s: invalid device data!!\n" , __func__); +of_node_put (np_ddr); goto error; }/*
@@ -1139,6 +1141,7 @@ static void emif_remove(struct platform_device *pdev)struct emif_data *emif =platform_get_drvdata (pdev);emif_debugfs_exit (emif); +of_node_put (emif->np_ddr); }static void emif_shutdown (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/1756 RDMA/rxe: Use validated num_sge in local buffer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Morey <[email protected]>
[ Upstream commit a4368022a3ac5324356ae8d88e3a42d115956fd6 ]
For both SRQ and non-SRQ receive paths, the WQE is copied into a local buffer to provide a kernel-owned, validated copy. While calculating the memcpy size from the validated num_sge prevents overflow during the copy, memcpy() itself still copies num_sge from shared memory.
A concurrent userspace modification before or during memcpy() leaves an unvalidated num_sge in the local buffer, leading to potential out-of-bounds reads in rxe_resp_check_length() and copy_data() causing:
BUG: KASAN: slab-out-of-bounds in rxe_receiver+0x8109/0x9ec0 [rdma_rxe] Read of size 4 at addr ffff88812c4867f8 by task kworker/u9:6/361 Workqueue: rxe_wq do_work [rdma_rxe] Call Trace: rxe_receiver+0x8109/0x9ec0 [rdma_rxe] do_work+0x149/0x610 [rdma_rxe] process_one_work+0x726/0x10a0 The buggy address belongs to the object at ffff88812c486000 which belongs to the cache kmalloc-part-13-2k of size 2048 The buggy address is located 0 bytes to the right of allocated 2040-byte region [ffff88812c486000, ffff88812c4867f8)
Explicitly assign the validated num_sge to the local buffer after the copy to prevent this race.
--- drivers/infiniband/sw/rxe/rxe_resp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/sw/rxe/rxe_resp.c +2 -0
@@ -287,6 +287,7 @@ static enum resp_states get_srq_wqe(struct rxe_qp *qp) } size =sizeof (*wqe) + num_sge *sizeof (struct rxe_sge );memcpy (&qp->resp.srq_wqe, wqe, size); + qp->resp.srq_wqe.wqe.dma.num_sge = num_sge; qp->resp.wqe = &qp->resp.srq_wqe.wqe;queue_advance_consumer (q,QUEUE_TYPE_FROM_CLIENT );
@@ -327,6 +328,7 @@ static enum resp_states rxe_get_recv_wqe(struct rxe_qp *qp) } size =sizeof (*wqe) + num_sge *sizeof (struct rxe_sge );memcpy (&qp->resp.srq_wqe, wqe, size); + qp->resp.srq_wqe.wqe.dma.num_sge = num_sge; qp->resp.wqe = &qp->resp.srq_wqe.wqe;return RESPST_CHK_LENGTH ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/1756 RDMA/uverbs: Make CQ handle mandatory for WQ creation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit f7d28791433d373ecdab7b00f60ddb504e858e0a ]
UVERBS_ATTR_CREATE_WQ_CQ_HANDLE is declared UA_OPTIONAL in the ioctl method definition, so the mandatory attribute bitmap does not enforce its presence. When userspace omits it, uverbs_attr_get_obj() returns ERR_PTR(-ENOENT) and the handler stores that error pointer into wq_init_attr.cq without validation.
The bogus cq pointer is then passed to the driver's create_wq callback. In the mlx5 case, create_rq() calls to_mcq(init_attr->cq) which applies container_of to the ERR_PTR value, producing a near-NULL pointer. The subsequent access in get_rq_ts_format() triggers a kernel NULL pointer dereference:
BUG: kernel NULL pointer dereference, address: 0000000000000296 RIP: 0010:create_rq+0x32/0x550 [mlx5_ib] Call Trace: mlx5_ib_create_wq+0x14a/0x210 [mlx5_ib] ib_uverbs_handler_UVERBS_METHOD_WQ_CREATE+0x1f0/0x320 [ib_uverbs] ib_uverbs_run_method+0x296/0x320 [ib_uverbs] ib_uverbs_cmd_verbs+0x1a0/0x260 [ib_uverbs] ib_uverbs_ioctl+0xa8/0x120 [ib_uverbs]
A WQ without a CQ was never valid; the legacy write path always required one via uobj_get_obj_read() in ib_uverbs_ex_create_wq(). Declare the attribute UA_MANDATORY so the uverbs framework rejects the ioctl early when the CQ handle is missing, before the handler ever runs.
--- drivers/infiniband/core/uverbs_std_types_wq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_std_types_wq.c +1 -1
@@ -140,7 +140,7 @@ DECLARE_UVERBS_NAMED_METHOD(UVERBS_ATTR_IDR (UVERBS_ATTR_CREATE_WQ_CQ_HANDLE ,UVERBS_OBJECT_CQ ,UVERBS_ACCESS_READ , -UA_OPTIONAL ), +UA_MANDATORY ), UVERBS_ATTR_FD(UVERBS_ATTR_CREATE_WQ_EVENT_FD, UVERBS_OBJECT_ASYNC_EVENT, UVERBS_ACCESS_READ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/1756 media: i2c: ar0521: remove duplicate media entity cleanup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 069a0343581bfcaee44bc598e2b95be2e2789807 ]
The error path taken when ar0521_power_on() fails calls media_entity_cleanup() at the disable label and then falls through to the entity_cleanup label, where media_entity_cleanup() is called again.
There is no need to clean up the media entity twice. Remove the first call and let all error paths converge on the common entity_cleanup label.
This issue was found by manual code inspection.
--- drivers/media/i2c/ar0521.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/i2c/ar0521.c +0 -1
@@ -1140,7 +1140,6 @@ static int ar0521_probe(struct i2c_client *client) disable:v4l2_async_unregister_subdev (&sensor->sd); -media_entity_cleanup (&sensor->sd.entity); free_ctrls:v4l2_ctrl_handler_free (&sensor->ctrls.handler); entity_cleanup:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/1756 block: Fix the thaw_bdev reference in bdev_freeze() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit e14c3379be86854c203de1e0fdfdeaa0b45509df ]
The kernel-doc comment of bdev_freeze() refers to thaw_bdev, which was renamed to bdev_thaw by commit 982c3b305843 ("bdev: rename freeze and thaw helpers"). Say bdev_thaw.
--- block/bdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/bdev.c +1 -1
@@ -253,7 +253,7 @@ EXPORT_SYMBOL(sync_blockdev_range);* The reference counter (bd_fsfreeze_count) guarantees that only the last * unfreeze process can unfreeze the frozen filesystem actually when multiple * freeze requests arrive simultaneously. It counts up in bdev_freeze() and -* count down in bdev_thaw(). When it becomes 0, thaw_bdev() will unfreeze +* count down in bdev_thaw(). When it becomes 0, bdev_thaw() will unfreeze * actually. * * Return: On success zero is returned, negative error code on failure.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/1756 remoteproc: core: Set trace buffer name for diagnostics
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghao Zhang <[email protected]>
[ Upstream commit e23eab619b0d2dd796618406ba25da62f4d539a2 ]
rproc_trace_read() (in remoteproc_debugfs.c) prints the name of a trace buffer whose device address could not be resolved, but nothing ever assigns trace_mem.name, so that the diagnostics always prints an empty string:
Trace not available
Copy the generated "trace%d" name into the memory entry, so the diagnostics identifies the buffer failed to translate.
--- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/remoteproc_core.c +3 -0
@@ -579,6 +579,9 @@ static int rproc_handle_trace(struct rproc *rproc, void *ptr,/* create the debugfs entry */ trace->tfile =rproc_create_trace_file (name, rproc, trace); +/* keep the name for the diagnostic in rproc_trace_read() */ +strscpy (trace->trace_mem.name, name,sizeof (trace->trace_mem.name)); +list_add_tail (&trace->node, &rproc->traces); rproc->num_traces++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/1756 dmaengine: mv_xor: kill tasklet on channel add error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit bcb4d469b19d53dc21e4a1da12d4438e7489e150 ]
If request_irq() succeeds but a later step (self-test or device registration) fails, the error path at err_free_irq frees the IRQ but does not kill the tasklet. A previously scheduled tasklet can still run after the channel is freed, accessing freed memory.
Add tasklet_kill() after free_irq() on the error path.
--- drivers/dma/mv_xor.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/mv_xor.c +1 -0
@@ -1162,6 +1162,7 @@ mv_xor_channel_add(struct mv_xor_device *xordev, err_free_irq:free_irq (mv_chan->irq, mv_chan); +tasklet_kill (&mv_chan->irq_tasklet); err_free_dma:dma_free_wc (&pdev->dev,MV_XOR_POOL_SIZE , mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/1756 loadpin: Fix stale KEXEC_VERIFY_SIG reference in documentation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit eb0b0d222a832b6ec851e56d4922a775ac762955 ]
Commit 99d5cadfde2b ("kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE") removed CONFIG_KEXEC_VERIFY_SIG but left the LoadPin documentation pointing at it. Refer to CONFIG_KEXEC_SIG instead.
While at it, clean up the grammar of the sentence.
Message-ID: <[email protected]>
--- Documentation/admin-guide/LSM/LoadPin.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/admin-guide/LSM/LoadPin.rst +5 -5
@@ -23,9 +23,9 @@ sysctl allows for easy testing on systems with a mutable filesystem.) It's also possible to exclude specific file types from LoadPin using kernel command line option "``loadpin.exclude``". By default, all files are included, but they can be excluded using kernel command line option such -as "``loadpin.exclude=kernel-module,kexec-image``". This allows to use +as "``loadpin.exclude=kernel-module,kexec-image``". This allows using different mechanisms such as ``CONFIG_MODULE_SIG`` and -``CONFIG_KEXEC_VERIFY_SIG`` to verify kernel module and kernel image while -still use LoadPin to protect the integrity of other files kernel loads. The -full list of valid file types can be found in ``kernel_read_file_str`` -defined in ``include/linux/kernel_read_file.h``. +``CONFIG_KEXEC_SIG`` to verify kernel modules and kernel images while +still using LoadPin to protect the integrity of other files the kernel +loads. The full list of valid file types can be found in +``kernel_read_file_str`` defined in ``include/linux/kernel_read_file.h``.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/1756 wifi: rtw88: sdio: zero the padding added to a TX transfer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luka Gejak <[email protected]>
[ Upstream commit b81ead28aeb1fd9bc3b0de4e20342b6b538ac658 ]
rtw_sdio_write_port() rounds the transfer up with sdio_align_size() and then hands that length to sdio_memcpy_toio() while the skb still only holds skb->len bytes. The difference, between one and 511 bytes, is read from beyond the end of the frame and transmitted. Whether it stays inside the skb's allocation depends on how much tailroom the skb happens to have, so this is at best sending uninitialised memory over the air.
Pad the skb up to the transfer size first. __skb_pad() zeroes the added bytes, reallocates a cloned skb rather than writing into a buffer a clone still shares, and leaves skb->len alone, so nothing else in the transmit path has to change.
It must not free the skb on failure: rtw_sdio_write_data() frees the skb itself and rtw_sdio_process_tx_queue() requeues it, so both callers still own it and would double free.
Found while reworking this path for the RTL8723BS. Measured on RTL8723BS hardware, padding the transfer costs about 2% observable over transfer:
uplink is 19.5 to 19.8 Mbit/s padded against 20.9 to 21.1 Mbit/s unpadded in an interleaved A/B, with scans, reconnection and a UDP flood clean in both. The other SDIO parts sharing this path are untested; I have only the RTL8723BS.
--- drivers/net/wireless/realtek/rtw88/sdio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/wireless/realtek/rtw88/sdio.c +12 -0
@@ -636,6 +636,7 @@ static int rtw_sdio_write_port(struct rtw_dev *rtwdev, struct sk_buff *skb, enum rtw_tx_queue_type queue) {struct rtw_sdio *rtwsdio = (struct rtw_sdio *)rtwdev->priv; +size_t pad_size;bool bus_claim;size_t txsize;u32 txaddr;
@@ -646,6 +647,17 @@ static int rtw_sdio_write_port(struct rtw_dev *rtwdev, struct sk_buff *skb,return -EINVAL ; txsize =sdio_align_size (rtwsdio->sdio_func, skb->len); + pad_size = txsize - skb->len; + +if (pad_size >0 ) { +/* +* __skb_pad() must not free the skb on failure: both callers +* still own it, one requeues it and the other frees it. +*/ + ret =__skb_pad (skb, pad_size, false); +if (ret) +return ret; + } ret =rtw_sdio_check_free_txpg (rtwdev, queue, txsize);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/1756 ntfs3: fix out-of-bounds read in ntfs_read_mft()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 7a374d9be8267834dc534e55f01e5e01765cab4c ]
ntfs_read_mft() walks the attributes of an MFT record and, for each FILE_NAME attribute, compares the resident on-disk name with the name being looked up. The only size check before the compare is rsize >= SIZEOF_ATTRIBUTE_FILENAME, which covers the fixed header up to and including name_len, but not the variable-length name that follows it.
name_len comes straight from disk and is not validated against the resident data_size. A crafted image can set name_len large while keeping data_size at the header size, so ntfs_cmp_names_cpu() reads name_len le16 characters past the end of the MFT record buffer:
BUG: KASAN: slab-out-of-bounds in ntfs_cmp_names_cpu (fs/ntfs3/upcase.c:84) Read of size 2 at addr ffff888031879c00 by task a.out ntfs_cmp_names_cpu (fs/ntfs3/upcase.c:84) ntfs_iget5 (fs/ntfs3/inode.c:209) dir_search_u (fs/ntfs3/dir.c:265) ntfs_lookup (fs/ntfs3/namei.c:85) __lookup_slow (fs/namei.c:1915) lookup_slow (fs/namei.c:1932) path_lookupat (fs/namei.c:2278) vfs_statx (fs/stat.c) vfs_fstatat (fs/stat.c) __do_sys_newfstatat (fs/stat.c)
Allocated by task:
mi_init (fs/ntfs3/record.c)
ntfs_iget5 (fs/ntfs3/inode.c)
dir_search_u (fs/ntfs3/dir.c)
ntfs_lookup (fs/ntfs3/namei.c)
Check that the name fits in the resident data before using it.
--- fs/ntfs3/inode.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ntfs3/inode.c +5 -0
@@ -208,6 +208,11 @@ static struct inode *ntfs_read_mft(struct inode *inode, names +=1 ; fname =Add2Ptr (attr, roff); + +/* Make sure the full name fits in the resident data. */ +if (rsize <fname_full_size (fname)) + goto out; +if (fname->type ==FILE_NAME_DOS ) goto next_attr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/1756 mm/gup_test: reject wrapped user ranges
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit e8ae6fd67021fafa9205330b3b248c9fc7216e0b ]
gup_test accepts an address and size from the debugfs ioctl and repeatedly compares against addr + size. If that addition wraps, the loop can be skipped and the ioctl returns success with size rewritten to zero.
Compute the end address once with overflow checking and use that checked end for the loop bounds.
Stable-dep-of: 44817a536aaa ("mm/gup_test: safely calculate GUP batch size")
--- mm/gup_test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/gup_test.c +8 -4
@@ -104,11 +104,15 @@ static int __gup_test_ioctl(unsigned int cmd,unsigned long i, nr_pages, addr, next;long nr;struct page **pages; +unsigned long end;int ret =0 ;bool needs_mmap_lock = cmd !=GUP_FAST_BENCHMARK && cmd !=PIN_FAST_BENCHMARK ; -if (gup->size >ULONG_MAX ) +if (gup->addr >ULONG_MAX || gup->size >ULONG_MAX ) +return -EINVAL ; +if (check_add_overflow ((unsigned long )gup->addr, + (unsigned long )gup->size, &end))return -EINVAL ; nr_pages = gup->size /PAGE_SIZE ;
@@ -124,13 +128,13 @@ static int __gup_test_ioctl(unsigned int cmd, i =0 ; nr = gup->nr_pages_per_call; start_time =ktime_get (); -for (addr = gup->addr; addr < gup->addr + gup->size; addr = next) { +for (addr = gup->addr; addr < end; addr = next) {if (nr != gup->nr_pages_per_call)break ; next = addr + nr *PAGE_SIZE ; -if (next > gup->addr + gup->size) { - next = gup->addr + gup->size; +if (next > end) { + next = end; nr = (next - addr) /PAGE_SIZE ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/1756 mm/gup_test: safely calculate GUP batch size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarthak Sharma <[email protected]>
[ Upstream commit 44817a536aaa5bfac0d316242e93e489d0a69d5f ]
__gup_test_ioctl() calculates the end of a GUP batch using:
next = addr + nr * PAGE_SIZE;
If nr is too large, it can cause next to overflow and wrap around. If it wraps, the next > end check is bypassed and a large value of nr is passed to the GUP call, even though the pages array was allocated according to gup->size. This can lead to out of bounds writes.
Also, when fewer than PAGE_SIZE bytes remain, the calculated batch contains zero pages. The code still calls GUP functions with pages + i, which can point past the allocated array.
Calculate nr by taking the minimum of the number of pages per call and the pages remaining in the address range. Reject zero sized and non page aligned gup->size values and zero nr_pages_per_call value.
--- mm/gup_test.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
mm/gup_test.c +4 -5
@@ -109,7 +109,8 @@ static int __gup_test_ioctl(unsigned int cmd,bool needs_mmap_lock = cmd !=GUP_FAST_BENCHMARK && cmd !=PIN_FAST_BENCHMARK ; -if (gup->addr >ULONG_MAX || gup->size >ULONG_MAX ) +if (gup->addr >ULONG_MAX || gup->size >ULONG_MAX || !gup->size || + !gup->nr_pages_per_call || !PAGE_ALIGNED (gup->size))return -EINVAL ;if (check_add_overflow ((unsigned long )gup->addr, (unsigned long )gup->size, &end))
@@ -132,11 +133,9 @@ static int __gup_test_ioctl(unsigned int cmd,if (nr != gup->nr_pages_per_call)break ; + nr = min_t(unsigned long, nr, (end - addr) / PAGE_SIZE); + next = addr + nr *PAGE_SIZE ; -if (next > end) { - next = end; - nr = (next - addr) /PAGE_SIZE ; - }switch (cmd) {case GUP_FAST_BENCHMARK :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/1756 mm/gup_test: report actual pinned bytes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarthak Sharma <[email protected]>
[ Upstream commit 65a79b9b693d8c7bd7e5e4865c02cce922a7cc50 ]
__gup_test_ioctl() advances addr to the end of the current batch before checking if GUP pinned the entire requested batch. If GUP pins more than 0 pages but less than the requested batch size, addr still advances by the requested batch size.
The next iteration detects the partial pinning and breaks out of the loop. Again gup->size is calculated using addr - gup->addr, so it also includes the unpinned pages of the requested batch.
Calculate gup->size using the actual number of pages pinned multiplied by PAGE_SIZE.
--- mm/gup_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/gup_test.c +1 -1
@@ -180,7 +180,7 @@ static int __gup_test_ioctl(unsigned int cmd, nr_pages = i; gup->get_delta_usec =ktime_us_delta (end_time, start_time); - gup->size = addr - gup->addr; + gup->size = nr_pages *PAGE_SIZE ;/* * Take an un-benchmark-timed moment to verify DMA pinned
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/1756 arm64: dts: mediatek: mt8173: Fix MFG_ASYNC power domain clock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit c9b3c82c9f1f86cdb2449d47e4ca66a19159ee12 ]
The MFG_ASYNC domain, which is likely associated to the whole MFG block, currently specifies clk26m as its domain clock. This is bogus, since the clock is an external crystal with no controls. Also, the MFG block has a independent CLK_TOP_AXI_MFG_IN_SEL clock, which according to the block diagram, gates access to the hardware registers. Having this one as the domain clock makes much more sense. This also fixes access to the MFGTOP registers.
Change the MFG_ASYNC domain clock to CLK_TOP_AXI_MFG_IN_SEL.
--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +1 -1
@@ -497,7 +497,7 @@ power-domain@MT8173_POWER_DOMAIN_USB { }; mfg_async: power-domain@MT8173_POWER_DOMAIN_MFG_ASYNC { reg = <MT8173_POWER_DOMAIN_MFG_ASYNC>; - clocks = <&clk26m>; + clocks = <&topckgen CLK_TOP_AXI_MFG_IN_SEL>; clock-names = "mfg"; #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/1756 ACPI: tables: handle failed initrd override mappings
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit 047c834d939df75386cfc0603c7ddeaa23a349a4 ]
The runtime AML table-loading path can invoke initrd override after permanent mappings are enabled. Mapping bookkeeping can then fail.
Return AE_NO_MEMORY in that case to prevent a NULL pointer dereference when attempting to read the table length.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- drivers/acpi/tables.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/tables.c +3 -0
@@ -559,6 +559,9 @@ acpi_table_initrd_override(struct acpi_table_header *existing_table,while (table_offset +ACPI_HEADER_SIZE <= all_tables_size) { table =acpi_os_map_memory (acpi_tables_addr + table_offset,ACPI_HEADER_SIZE ); +if (!table) +return AE_NO_MEMORY ; +if (table_offset + table->length > all_tables_size) {acpi_os_unmap_memory (table,ACPI_HEADER_SIZE );WARN_ON (1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/1756 cxl/hdm: Reject switch decoder interleave ways that overflow targets
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 3696326ca14cf018788d64232a068fdf26b1ff31 ]
Switch decoder enumeration validates that the interleave ways encoding is legal, but not that the resulting number of ways fits the available targets. This can overrun the target array (target_list.target_id[]) during enumeration of 12 or 16 way interleaves.
Bound the target count where it is established rather than at each use. Reject an HDM capability whose reported target count is zero or exceeds the target list register capacity, and reject a zero target switch decoder allocation in cxl_switch_decoder_init(). Enumeration is then left with a single check: reject a decoder whose interleave ways exceed the targets it has.
Add a clarifying comment that target_count is a direct count, not 0-based like decoder_count.
--- drivers/cxl/core/hdm.c | 24 ++++++++++++++++++++++++ drivers/cxl/core/port.c | 2 +- drivers/cxl/cxl.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/cxl/core/hdm.c +24 -0
@@ -81,6 +81,8 @@ static void parse_hdm_decoder_caps(struct cxl_hdm *cxlhdm) hdm_cap =readl (cxlhdm->regs.hdm_decoder +CXL_HDM_DECODER_CAP_OFFSET ); cxlhdm->decoder_count =cxl_hdm_decoder_count (hdm_cap); + +/* target_count is a direct count (1h..8h), not 0-based like decoder_count */ cxlhdm->target_count =FIELD_GET (CXL_HDM_DECODER_TARGET_COUNT_MASK , hdm_cap);if (FIELD_GET (CXL_HDM_DECODER_INTERLEAVE_11_8 , hdm_cap))
@@ -938,6 +940,16 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, cxld->interleave_ways, cxld->interleave_granularity);if (!cxled) { +struct cxl_switch_decoder *cxlsd =to_cxl_switch_decoder (&cxld->dev); + +if (cxld->interleave_ways > cxlsd->nr_targets) { +dev_err (&port->dev, +"decoder%d.%d: interleave ways: %d exceeds targets: %d\n" , + port->id, cxld->id, cxld->interleave_ways, + cxlsd->nr_targets); +return -ENXIO ; + } + lo =readl (hdm +CXL_HDM_DECODER0_TL_LOW (which)); hi =readl (hdm +CXL_HDM_DECODER0_TL_HIGH (which)); target_list.value = (hi <<32 ) + lo;
@@ -1015,6 +1027,18 @@ int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,int i;u64 dpa_base =0 ; +/* +* Per CXL 4.0 8.2.4.20.1 Target Count is the number of target ports +* per decoder, max 8. Endpoint decoders have no targets. +*/ +if (!is_cxl_endpoint (port) && + (cxlhdm->target_count <1 || + cxlhdm->target_count >CXL_HDM_DECODER0_TL_TARGETS )) { +dev_err (&port->dev,"Invalid decoder target count: %u\n" , + cxlhdm->target_count); +return -ENXIO ; + } +cxl_settle_decoders (cxlhdm);for (i =0 ; i < cxlhdm->decoder_count; i++) {
drivers/cxl/core/port.c +1 -1
@@ -1787,7 +1787,7 @@ static int cxl_switch_decoder_init(struct cxl_port *port, struct cxl_switch_decoder *cxlsd, int nr_targets) { -if (nr_targets >CXL_DECODER_MAX_INTERLEAVE ) +if (nr_targets <1 || nr_targets >CXL_DECODER_MAX_INTERLEAVE )return -EINVAL ; cxlsd->nr_targets = nr_targets;
drivers/cxl/cxl.h +2 -0
@@ -65,6 +65,8 @@ extern const struct nvdimm_security_ops *cxl_security_ops;#define CXL_HDM_DECODER0_CTRL_HOSTONLY BIT(12)#define CXL_HDM_DECODER0_TL_LOW (i) (0x20 * (i) + 0x24)#define CXL_HDM_DECODER0_TL_HIGH (i) (0x20 * (i) + 0x28) +/* Target list capacity, i.e. max interleave ways for a non-endpoint decoder */ +#define CXL_HDM_DECODER0_TL_TARGETS 8#define CXL_HDM_DECODER0_SKIP_LOW (i) CXL_HDM_DECODER0_TL_LOW(i)#define CXL_HDM_DECODER0_SKIP_HIGH (i) CXL_HDM_DECODER0_TL_HIGH(i)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/1756 cxl: Add a cached copy of target_map to cxl_decoder
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 02edab6ceefaaf8cb917e864d8c26dbac0ea9686 ]
Add a cached copy of the hardware port-id list that is available at init before all @dport objects have been instantiated. Change is in preparation of delayed dport instantiation.
Stable-dep-of: 3f846646b3d3 ("cxl/hdm: Make switch decoder target parsing endian-safe")
--- drivers/cxl/acpi.c | 7 +++---- drivers/cxl/core/hdm.c | 20 ++++++++------------ drivers/cxl/core/port.c | 22 +++++++--------------- drivers/cxl/core/region.c | 4 +++- drivers/cxl/cxl.h | 8 ++++++-- tools/testing/cxl/test/cxl.c | 8 ++++---- 6 files changed, 31 insertions(+), 38 deletions(-)
drivers/cxl/acpi.c +3 -4
@@ -349,7 +349,6 @@ DEFINE_FREE(del_cxl_resource, struct resource *, if (_T) del_cxl_resource(_T))static int __cxl_parse_cfmws (struct acpi_cedt_cfmws *cfmws,struct cxl_cfmws_context *ctx) { -int target_map[CXL_DECODER_MAX_INTERLEAVE ];struct cxl_port *root_port = ctx->root_port;struct cxl_cxims_context cxims_ctx;struct device *dev = ctx->dev;
@@ -367,8 +366,6 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws, rc =eig_to_granularity (cfmws->granularity, &ig);if (rc)return rc; -for (i =0 ; i < ways; i++) - target_map[i] = cfmws->interleave_targets[i]; struct resource *res __free(del_cxl_resource) = alloc_cxl_resource( cfmws->base_hpa, cfmws->window_size, ctx->id++);
@@ -394,6 +391,8 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws, .end = cfmws->base_hpa + cfmws->window_size - 1, }; cxld->interleave_ways = ways; +for (i =0 ; i < ways; i++) + cxld->target_map[i] = cfmws->interleave_targets[i];/* * Minimize the x1 granularity to advertise support for any * valid region granularity
@@ -424,7 +423,7 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,if (cfmws->interleave_arithmetic ==ACPI_CEDT_CFMWS_ARITHMETIC_XOR ) cxlrd->hpa_to_spa = cxl_xor_hpa_to_spa; - rc =cxl_decoder_add (cxld, target_map); + rc =cxl_decoder_add (cxld);if (rc)return rc;return cxl_root_decoder_autoremove (dev,no_free_ptr (cxlrd));
drivers/cxl/core/hdm.c +8 -12
@@ -18,12 +18,11 @@DECLARE_RWSEM (cxl_dpa_rwsem); -static int add_hdm_decoder (struct cxl_port *port,struct cxl_decoder *cxld, -int *target_map) +static int add_hdm_decoder (struct cxl_port *port,struct cxl_decoder *cxld) {int rc; - rc =cxl_decoder_add_locked (cxld, target_map); + rc =cxl_decoder_add_locked (cxld);if (rc) {put_device (&cxld->dev);dev_err (&port->dev,"Failed to add decoder\n" );
@@ -50,7 +49,6 @@ int devm_cxl_add_passthrough_decoder(struct cxl_port *port) {struct cxl_switch_decoder *cxlsd;struct cxl_dport *dport =NULL ; -int single_port_map[1 ];unsigned long index;struct cxl_hdm *cxlhdm =dev_get_drvdata (&port->dev);
@@ -69,9 +67,9 @@ int devm_cxl_add_passthrough_decoder(struct cxl_port *port)xa_for_each (&port->dports, index, dport)break ; - single_port_map[0 ] = dport->port_id; + cxlsd->cxld.target_map[0 ] = dport->port_id; -return add_hdm_decoder (port, &cxlsd->cxld, single_port_map); +return add_hdm_decoder (port, &cxlsd->cxld); }EXPORT_SYMBOL_NS_GPL (devm_cxl_add_passthrough_decoder,CXL );
@@ -825,7 +823,7 @@ static int cxl_setup_hdm_decoder_from_dvsec( }static int init_hdm_decoder (struct cxl_port *port,struct cxl_decoder *cxld, -int *target_map,void __iomem *hdm,int which, +void __iomem *hdm,int which,u64 *dpa_base,struct cxl_endpoint_dvsec_info *info) {struct cxl_endpoint_decoder *cxled =NULL ;
@@ -954,7 +952,7 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, hi =readl (hdm +CXL_HDM_DECODER0_TL_HIGH (which)); target_list.value = (hi <<32 ) + lo;for (i =0 ; i < cxld->interleave_ways; i++) - target_map[i] = target_list.target_id[i]; + cxld->target_map[i] = target_list.target_id[i];return 0 ; }
@@ -1042,7 +1040,6 @@ int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,cxl_settle_decoders (cxlhdm);for (i =0 ; i < cxlhdm->decoder_count; i++) { -int target_map[CXL_DECODER_MAX_INTERLEAVE ] = {0 };int rc, target_count = cxlhdm->target_count;struct cxl_decoder *cxld;
@@ -1070,8 +1067,7 @@ int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, cxld = &cxlsd->cxld; } - rc =init_hdm_decoder (port, cxld, target_map, hdm, i, - &dpa_base, info); + rc =init_hdm_decoder (port, cxld, hdm, i, &dpa_base, info);if (rc) { dev_warn(&port->dev, "Failed to initialize decoder%d.%d\n",
@@ -1079,7 +1075,7 @@ int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,put_device (&cxld->dev);return rc; } - rc =add_hdm_decoder (port, cxld, target_map); + rc =add_hdm_decoder (port, cxld);if (rc) {dev_warn (&port->dev,"Failed to add decoder%d.%d\n" , port->id, i);
drivers/cxl/core/port.c +7 -15
@@ -1715,13 +1715,11 @@ struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd,EXPORT_SYMBOL_NS_GPL (cxl_mem_find_port,CXL );static int decoder_populate_targets (struct cxl_switch_decoder *cxlsd, -struct cxl_port *port,int *target_map) +struct cxl_port *port) { +struct cxl_decoder *cxld = &cxlsd->cxld;int i; -if (!target_map) -return 0 ; -device_lock_assert (&port->dev);if (xa_empty (&port->dports))
@@ -1729,7 +1727,7 @@ static int decoder_populate_targets(struct cxl_switch_decoder *cxlsd,guard (rwsem_write)(&cxl_region_rwsem);for (i =0 ; i < cxlsd->cxld.interleave_ways; i++) { -struct cxl_dport *dport =find_dport (port, target_map[i]); +struct cxl_dport *dport =find_dport (port, cxld->target_map[i]);if (!dport)return -ENXIO ;
@@ -1921,9 +1919,6 @@ EXPORT_SYMBOL_NS_GPL(cxl_endpoint_decoder_alloc, CXL);/** * cxl_decoder_add_locked - Add a decoder with targets * @cxld: The cxl decoder allocated by cxl_<type>_decoder_alloc() -* @target_map: A list of downstream ports that this decoder can direct memory -* traffic to. These numbers should correspond with the port number -* in the PCIe Link Capabilities structure. * * Certain types of decoders may not have any targets. The main example of this * is an endpoint device. A more awkward example is a hostbridge whose root
@@ -1937,7 +1932,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_endpoint_decoder_alloc, CXL);* Return: Negative error code if the decoder wasn't properly configured; else * returns 0. */ -int cxl_decoder_add_locked (struct cxl_decoder *cxld,int *target_map) +int cxl_decoder_add_locked (struct cxl_decoder *cxld) {struct cxl_port *port;struct device *dev;
@@ -1958,7 +1953,7 @@ int cxl_decoder_add_locked(struct cxl_decoder *cxld, int *target_map)if (!is_endpoint_decoder (dev)) {struct cxl_switch_decoder *cxlsd =to_cxl_switch_decoder (dev); - rc =decoder_populate_targets (cxlsd, port, target_map); + rc =decoder_populate_targets (cxlsd, port);if (rc && (cxld->flags &CXL_DECODER_F_ENABLE )) {dev_err (&port->dev,"Failed to populate active decoder targets\n" );
@@ -1977,9 +1972,6 @@ EXPORT_SYMBOL_NS_GPL(cxl_decoder_add_locked, CXL);/** * cxl_decoder_add - Add a decoder with targets * @cxld: The cxl decoder allocated by cxl_<type>_decoder_alloc() -* @target_map: A list of downstream ports that this decoder can direct memory -* traffic to. These numbers should correspond with the port number -* in the PCIe Link Capabilities structure. * * This is the unlocked variant of cxl_decoder_add_locked(). * See cxl_decoder_add_locked().
@@ -1987,7 +1979,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_decoder_add_locked, CXL);* Context: Process context. Takes and releases the device lock of the port that * owns the @cxld. */ -int cxl_decoder_add (struct cxl_decoder *cxld,int *target_map) +int cxl_decoder_add (struct cxl_decoder *cxld) {struct cxl_port *port;
@@ -2000,7 +1992,7 @@ int cxl_decoder_add(struct cxl_decoder *cxld, int *target_map) port =to_cxl_port (cxld->dev.parent);guard (device)(&port->dev); -return cxl_decoder_add_locked (cxld, target_map); +return cxl_decoder_add_locked (cxld); }EXPORT_SYMBOL_NS_GPL (cxl_decoder_add,CXL );
drivers/cxl/core/region.c +3 -1
@@ -1478,8 +1478,10 @@ static int cxl_port_setup_targets(struct cxl_port *port, cxl_rr->nr_targets_set);return -ENXIO ; } - }else + }else { cxlsd->target[cxl_rr->nr_targets_set] = ep->dport; + cxlsd->cxld.target_map[cxl_rr->nr_targets_set] = ep->dport->port_id; + } inc =1 ; out_target_set: cxl_rr->nr_targets_set += inc;
drivers/cxl/cxl.h +6 -2
@@ -358,6 +358,9 @@ enum cxl_decoder_type {* @target_type: accelerator vs expander (type2 vs type3) selector * @region: currently assigned region for this decoder * @flags: memory type capabilities and locking +* @target_map: cached copy of hardware port-id list, available at init +* before all @dport objects have been instantiated. While +* dport id is 8bit, CFMWS interleave targets are 32bits. * @commit: device/decoder-type specific callback to commit settings to hw * @reset: device/decoder-type specific callback to reset hw settings */
@@ -370,6 +373,7 @@ struct cxl_decoder {enum cxl_decoder_type target_type;struct cxl_region *region;unsigned long flags; +u32 target_map[CXL_DECODER_MAX_INTERLEAVE ];int (*commit)(struct cxl_decoder *cxld);void (*reset)(struct cxl_decoder *cxld); };
@@ -798,9 +802,9 @@ struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port, unsigned int nr_targets);struct cxl_switch_decoder *cxl_switch_decoder_alloc (struct cxl_port *port,unsigned int nr_targets); -int cxl_decoder_add (struct cxl_decoder *cxld,int *target_map); +int cxl_decoder_add (struct cxl_decoder *cxld);struct cxl_endpoint_decoder *cxl_endpoint_decoder_alloc (struct cxl_port *port); -int cxl_decoder_add_locked (struct cxl_decoder *cxld,int *target_map); +int cxl_decoder_add_locked (struct cxl_decoder *cxld);int cxl_decoder_autoremove (struct device *host,struct cxl_decoder *cxld);static inline int cxl_root_decoder_autoremove (struct device *host,struct cxl_root_decoder *cxlrd)
tools/testing/cxl/test/cxl.c +4 -4
@@ -654,7 +654,7 @@ static int mock_cxl_add_passthrough_decoder(struct cxl_port *port)struct target_map_ctx { -int *target_map; +u32 *target_map;int index;int target_count; };
@@ -866,9 +866,7 @@ static int mock_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, target_count =NR_CXL_SWITCH_PORTS ;for (i =0 ; i <NR_CXL_PORT_DECODERS ; i++) { -int target_map[CXL_DECODER_MAX_INTERLEAVE ] = {0 };struct target_map_ctx ctx = { - .target_map = target_map, .target_count = target_count, };struct cxl_decoder *cxld;
@@ -897,6 +895,8 @@ static int mock_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, cxld = &cxled->cxld; } + ctx.target_map = cxld->target_map; +mock_init_hdm_decoder (cxld);if (target_count) {
@@ -908,7 +908,7 @@ static int mock_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, } } - rc =cxl_decoder_add_locked (cxld, target_map); + rc =cxl_decoder_add_locked (cxld);if (rc) {put_device (&cxld->dev);dev_err (&port->dev,"Failed to add decoder\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/1756 cxl/hdm: Make switch decoder target parsing endian-safe
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 3f846646b3d3b5699139e686e1107d231a725860 ]
Switch decoder target IDs are stored one per byte, starting with target 0 in the least significant byte. The current code accesses those bytes in memory order, which only matches register order on little-endian hosts.
On big-endian hosts, the target IDs are reversed and the decoder is associated with the wrong downstream ports.
Place the register values in a byte array in little-endian order and index the target IDs from there, so the target mapping is independent of host endianness.
--- drivers/cxl/core/hdm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/cxl/core/hdm.c +7 -8
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ #include <linux/seq_file.h> +#include <linux/unaligned.h> #include <linux/device.h> #include <linux/delay.h>
@@ -827,15 +828,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, u64 *dpa_base, struct cxl_endpoint_dvsec_info *info) { struct cxl_endpoint_decoder *cxled = NULL; +u8 target_id[CXL_HDM_DECODER0_TL_TARGETS ];u64 size, base, skip, dpa_size, lo, hi;bool committed;u32 remainder;int i, rc;u32 ctrl; -union { -u64 value; -unsigned char target_id[8 ]; - } target_list; if (should_emulate_decoders(info)) return cxl_setup_hdm_decoder_from_dvsec(port, cxld, dpa_base,
@@ -948,11 +946,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,return -ENXIO ; } - lo =readl (hdm +CXL_HDM_DECODER0_TL_LOW (which)); - hi =readl (hdm +CXL_HDM_DECODER0_TL_HIGH (which)); - target_list.value = (hi <<32 ) + lo; +put_unaligned_le32 (readl (hdm +CXL_HDM_DECODER0_TL_LOW (which)), + &target_id[0 ]); +put_unaligned_le32 (readl (hdm +CXL_HDM_DECODER0_TL_HIGH (which)), + &target_id[4 ]);for (i =0 ; i < cxld->interleave_ways; i++) - cxld->target_map[i] = target_list.target_id[i]; + cxld->target_map[i] = target_id[i];return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/1756 pinctrl: stm32: Declare stm32_pmx_get_mode() as static
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antonio Borneo <[email protected]>
[ Upstream commit 9b71efc450fdd2f70d59917025da34f8b0e81135 ]
The commit acaa037970f6 ("pinctrl: stm32: Implement .get_direction gpio_chip callback") exported the function stm32_pmx_get_mode() and the struct stm32_gpio_bank, but these were never used outside the file that defines them.
Declare the function as static, drop it from the include file and drop also the struct, not anymore visible outside the file.
Stable-dep-of: 01f20711d044 ("pinctrl: stm32: Drop the nonexistent CONFIG_MACH_STM32MP25 from the STM32MP257 default")
--- drivers/pinctrl/stm32/pinctrl-stm32.c | 5 +++-- drivers/pinctrl/stm32/pinctrl-stm32.h | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/pinctrl/stm32/pinctrl-stm32.c +3 -2
@@ -121,6 +121,8 @@ struct stm32_pinctrl {spinlock_t irqmux_lock; }; +static void stm32_pmx_get_mode (struct stm32_gpio_bank *bank,int pin,u32 *mode,u32 *alt); +static inline int stm32_gpio_pin (int gpio) {return gpio %STM32_GPIO_PINS_PER_BANK ;
@@ -795,8 +797,7 @@ static int stm32_pmx_set_mode(struct stm32_gpio_bank *bank,return err; } -void stm32_pmx_get_mode (struct stm32_gpio_bank *bank,int pin,u32 *mode, -u32 *alt) +static void stm32_pmx_get_mode (struct stm32_gpio_bank *bank,int pin,u32 *mode,u32 *alt) {u32 val;int alt_shift = (pin %8 ) *4 ;
drivers/pinctrl/stm32/pinctrl-stm32.h +0 -4
@@ -65,11 +65,7 @@ struct stm32_pinctrl_match_data {bool secure_control; }; -struct stm32_gpio_bank ; -int stm32_pctl_probe (struct platform_device *pdev); -void stm32_pmx_get_mode (struct stm32_gpio_bank *bank, -int pin,u32 *mode,u32 *alt);int stm32_pinctrl_suspend (struct device *dev);int stm32_pinctrl_resume (struct device *dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/1756 pinctrl: stm32: Allow compile as module for stm32mp257
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephane Danieau <[email protected]>
[ Upstream commit dba0aff2b89bd106601ed88dfda44fdd3218eb53 ]
Add ability to build pinctrl for stm32mp257 as a kernel module. Add kernel-doc to the exported symbols.
Stable-dep-of: 01f20711d044 ("pinctrl: stm32: Drop the nonexistent CONFIG_MACH_STM32MP25 from the STM32MP257 default")
--- arch/arm64/Kconfig.platforms | 1 - drivers/pinctrl/stm32/Kconfig | 6 +++--- drivers/pinctrl/stm32/pinctrl-stm32.c | 8 ++++++++ drivers/pinctrl/stm32/pinctrl-stm32.h | 14 ++++++++++++++ drivers/pinctrl/stm32/pinctrl-stm32mp257.c | 11 ++++++----- 5 files changed, 31 insertions(+), 9 deletions(-)
arch/arm64/Kconfig.platforms +0 -1
@@ -308,7 +308,6 @@ config ARCH_STM32 bool "STMicroelectronics STM32 SoC Family" select GPIOLIB select PINCTRL - select PINCTRL_STM32MP257 select ARM_SMC_MBOX select ARM_SCMI_PROTOCOL select REGULATOR
drivers/pinctrl/stm32/Kconfig +3 -3
@@ -2,7 +2,7 @@ if ARCH_STM32 || COMPILE_TEST config PINCTRL_STM32 - bool + tristate depends on OF select PINMUX select GENERIC_PINCONF
@@ -53,8 +53,8 @@ config PINCTRL_STM32MP157 select PINCTRL_STM32 config PINCTRL_STM32MP257 - bool "STMicroelectronics STM32MP257 pin control" if COMPILE_TEST && !MACH_STM32MP25 + tristate "STMicroelectronics STM32MP257 pin control" depends on OF && HAS_IOMEM - default MACH_STM32MP25 + default MACH_STM32MP25 || (ARCH_STM32 && ARM64) select PINCTRL_STM32 endif
drivers/pinctrl/stm32/pinctrl-stm32.c +8 -0
@@ -7,6 +7,7 @@* Heavily based on Mediatek's pinctrl driver */ #include <linux/clk.h> +#include <linux/export.h> #include <linux/gpio/driver.h> #include <linux/hwspinlock.h> #include <linux/io.h>
@@ -1666,6 +1667,7 @@ int stm32_pctl_probe(struct platform_device *pdev)clk_bulk_disable_unprepare (banks, pctl->clks);return ret; } +EXPORT_SYMBOL (stm32_pctl_probe);static int __maybe_unused stm32_pinctrl_restore_gpio_regs (struct stm32_pinctrl *pctl,u32 pin)
@@ -1738,6 +1740,7 @@ int __maybe_unused stm32_pinctrl_suspend(struct device *dev)return 0 ; } +EXPORT_SYMBOL (stm32_pinctrl_suspend);int __maybe_unused stm32_pinctrl_resume (struct device *dev) {
@@ -1754,3 +1757,8 @@ int __maybe_unused stm32_pinctrl_resume(struct device *dev)return 0 ; } +EXPORT_SYMBOL (stm32_pinctrl_resume); + +MODULE_AUTHOR ("Alexandre Torgue <[email protected]>" ); +MODULE_DESCRIPTION ("STM32 core pinctrl driver" ); +MODULE_LICENSE ("GPL" );
drivers/pinctrl/stm32/pinctrl-stm32.h +14 -0
@@ -65,8 +65,22 @@ struct stm32_pinctrl_match_data { bool secure_control; }; +/** +* stm32_pctl_probe() - Common probe for stm32 pinctrl drivers. +* @pdev: Pinctrl platform device. +*/ int stm32_pctl_probe (struct platform_device *pdev); + +/** +* stm32_pinctrl_suspend() - Common suspend for stm32 pinctrl drivers. +* @dev: Pinctrl device. +*/ int stm32_pinctrl_suspend (struct device *dev); + +/** +* stm32_pinctrl_resume() - Common resume for stm32 pinctrl drivers. +* @dev: Pinctrl device. +*/ int stm32_pinctrl_resume (struct device *dev);#endif /* __PINCTRL_STM32_H */
drivers/pinctrl/stm32/pinctrl-stm32mp257.c +6 -5
@@ -4,6 +4,7 @@* Author: Alexandre Torgue <[email protected]> for STMicroelectronics. */ #include <linux/init.h> +#include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h>
@@ -2560,6 +2561,7 @@ static const struct of_device_id stm32mp257_pctrl_match[] = { }, { } }; +MODULE_DEVICE_TABLE (of, stm32mp257_pctrl_match);static const struct dev_pm_ops stm32_pinctrl_dev_pm_ops = {SET_LATE_SYSTEM_SLEEP_PM_OPS (stm32_pinctrl_suspend, stm32_pinctrl_resume)
@@ -2573,9 +2575,8 @@ static struct platform_driver stm32mp257_pinctrl_driver = { .pm = &stm32_pinctrl_dev_pm_ops, }, }; +module_platform_driver (stm32mp257_pinctrl_driver); -static int __init stm32mp257_pinctrl_init (void ) -{ -return platform_driver_register (&stm32mp257_pinctrl_driver); -} -arch_initcall (stm32mp257_pinctrl_init); +MODULE_AUTHOR ("Alexandre Torgue <[email protected]>" ); +MODULE_DESCRIPTION ("STM32MP257 pinctrl driver" ); +MODULE_LICENSE ("GPL" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/1756 pinctrl: stm32: Drop the nonexistent CONFIG_MACH_STM32MP25 from the STM32MP257 default
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 01f20711d044f35a7a89ceec33df30e097147e8a ]
Commit 619f8ca4a73d ("pinctrl: stm32: add stm32mp257 pinctrl support") made CONFIG_PINCTRL_STM32MP257 default to MACH_STM32MP25, following the MACH_* pattern of the arm32 entries above it, but no Kconfig symbol of that name exists and git log -S finds no Kconfig file that ever defined
one: the STM32MP25 family is arm64 only, where CONFIG_ARCH_STM32 covers it. Commit dba0aff2b89b ("pinctrl: stm32: Allow compile as module for stm32mp257") added "|| (ARCH_STM32 && ARM64)" next to it, so the first half now evaluates to n and changes no configuration.
Drop the first half.
--- drivers/pinctrl/stm32/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/stm32/Kconfig +1 -1
@@ -55,6 +55,6 @@ config PINCTRL_STM32MP157 config PINCTRL_STM32MP257 tristate "STMicroelectronics STM32MP257 pin control" depends on OF && HAS_IOMEM - default MACH_STM32MP25 || (ARCH_STM32 && ARM64) + default ARCH_STM32 && ARM64 select PINCTRL_STM32 endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/1756 ASoC: SOF: imx: Prevent stack OOB read in DSP panic dump
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ștefan Ghețu <[email protected]>
[ Upstream commit 48ed992bfbe53537ad1cbc8ad68f7031e7ac0af3 ]
Commit 58bb5081cba1 ("ASoC: SOF: Xtensa: dump ar registers to restore call stack") added a shared Xtensa helper that iterates over a flexible array of AR registers (ar[]) controlled by plat_hdr.numaregs.
While Intel IPC4 allocates dynamic storage for the AR block, the i.MX IPC3 path reads the oops message into a stack-allocated struct without backing storage for ar[], while leaving numaregs unvalidated. This causes a stack out-of-bounds read when printing a DSP panic.
Clear numaregs to 0 on i.MX since the AR block is not fetched or supported on this platform, preventing unsafe out-of-bounds memory accesses in the shared Xtensa helper.
--- sound/soc/sof/imx/imx-common.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/sof/imx/imx-common.c +1 -0
@@ -29,6 +29,7 @@ void imx8_get_registers(struct snd_sof_dev *sdev,/* first read registers */ sof_mailbox_read (sdev, offset, xoops,sizeof (*xoops)); + xoops->plat_hdr.numaregs =0 ;/* then get panic info */ if (xoops->arch_hdr.totalsize >EXCEPT_MAX_HDR_SIZE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/1756 scsi: pm8001: Fix SATA FIS offset in struct hw_event_resp
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit cdc97921de02a0c1a8324afa03e8b3e30a72bbe6 ]
In struct hw_event_resp, sas_identify was defined using struct sas_identify_frame, which is 32 bytes long because it includes a 4-byte CRC field. However, PM8001 and PM80xx hardware does not send the CRC in the event response frame, providing only the 28-byte identify payload.
Because sas_identify had a size of 32 bytes, the following sata_fis member was located at byte offset 44 instead of the actual hardware offset 40. In hw_event_sata_phy_up(), this discrepancy was worked around with negative pointer arithmetic: ((u8 *)&pPayload->sata_fis - 4). This triggers a compiler error under Clang with -Wstringop-overread:
error: 'memcpy' reading 20 bytes from a region of size 0 [-Werror,-Wstringop-overread]
memcpy(phy->frame_rcvd, ((u8 *)&pPayload->sata_fis - 4),
Move struct sas_identify_frame_local (28 bytes) into pm8001_defs.h, and update struct hw_event_resp in both pm8001_hwi.h and pm80xx_hwi.h to use struct sas_identify_frame_local followed by sata_fis and a 4-byte padding word. This correctly aligns sata_fis at byte offset 40 while maintaining the 64-byte total payload size.
Update hw_event_sata_phy_up() in pm8001_hwi.c and pm80xx_hwi.c to copy directly from &pPayload->sata_fis.
Compile-tested only. Both the patch and its description have been generated by Gemini.
--- drivers/scsi/pm8001/pm8001_defs.h | 98 +++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.c | 2 +- drivers/scsi/pm8001/pm8001_hwi.h | 4 +- drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.h | 100 +----------------------------- 5 files changed, 106 insertions(+), 100 deletions(-)
drivers/scsi/pm8001/pm8001_defs.h +98 -0
@@ -41,6 +41,104 @@#ifndef _PM8001_DEFS_H_#define _PM8001_DEFS_H_ +#include <scsi/sas.h> + +#ifdef __LITTLE_ENDIAN_BITFIELD +struct sas_identify_frame_local { +/* Byte 0 */ +u8 frame_type:4 ; +u8 dev_type:3 ; +u8 _un0:1 ; + +/* Byte 1 */ +u8 _un1; + +/* Byte 2 */ +union { +struct { +u8 _un20:1 ; +u8 smp_iport:1 ; +u8 stp_iport:1 ; +u8 ssp_iport:1 ; +u8 _un247:4 ; + }; +u8 initiator_bits; + }; + +/* Byte 3 */ +union { +struct { +u8 _un30:1 ; +u8 smp_tport:1 ; +u8 stp_tport:1 ; +u8 ssp_tport:1 ; +u8 _un347:4 ; + }; +u8 target_bits; + }; + +/* Byte 4 - 11 */ +u8 _un4_11[8 ]; + +/* Byte 12 - 19 */ +u8 sas_addr[SAS_ADDR_SIZE ]; + +/* Byte 20 */ +u8 phy_id; + +u8 _un21_27[7 ]; + +} __packed; + +#elif defined(__BIG_ENDIAN_BITFIELD) +struct sas_identify_frame_local { +/* Byte 0 */ +u8 _un0:1 ; +u8 dev_type:3 ; +u8 frame_type:4 ; + +/* Byte 1 */ +u8 _un1; + +/* Byte 2 */ +union { +struct { +u8 _un247:4 ; +u8 ssp_iport:1 ; +u8 stp_iport:1 ; +u8 smp_iport:1 ; +u8 _un20:1 ; + }; +u8 initiator_bits; + }; + +/* Byte 3 */ +union { +struct { +u8 _un347:4 ; +u8 ssp_tport:1 ; +u8 stp_tport:1 ; +u8 smp_tport:1 ; +u8 _un30:1 ; + }; +u8 target_bits; + }; + +/* Byte 4 - 11 */ +u8 _un4_11[8 ]; + +/* Byte 12 - 19 */ +u8 sas_addr[SAS_ADDR_SIZE ]; + +/* Byte 20 */ +u8 phy_id; + +u8 _un21_27[7 ]; +} __packed; +#else +#error "Bitfield order not defined!" +#endif +enum chip_flavors { chip_8001, chip_8008,
drivers/scsi/pm8001/pm8001_hwi.c +1 -1
@@ -3209,7 +3209,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) phy->sas_phy.oob_mode =SATA_OOB_MODE ;sas_notify_phy_event (&phy->sas_phy,PHYE_OOB_DONE ,GFP_ATOMIC );spin_lock_irqsave (&phy->sas_phy.frame_rcvd_lock, flags); -memcpy (phy->frame_rcvd, ((u8 *)&pPayload->sata_fis -4 ), +memcpy (phy->frame_rcvd, &pPayload->sata_fis,sizeof (struct dev_to_host_fis )); phy->frame_rcvd_size =sizeof (struct dev_to_host_fis ); phy->identify.target_port_protocols =SAS_PROTOCOL_SATA ;
drivers/scsi/pm8001/pm8001_hwi.h +3 -1
@@ -42,6 +42,7 @@#include <linux/types.h> #include <scsi/libsas.h> +#include "pm8001_defs.h" /* for Request Opcode of IOMB */
@@ -229,8 +230,9 @@ struct hw_event_resp {__le32 lr_evt_status_phyid_portid;__le32 evt_param;__le32 npip_portstate; -struct sas_identify_frame sas_identify; +struct sas_identify_frame_local sas_identify;struct dev_to_host_fis sata_fis; +u32 _r_a; } __attribute__((packed, aligned(4)));
drivers/scsi/pm8001/pm80xx_hwi.c +1 -1
@@ -3241,7 +3241,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) phy->sas_phy.oob_mode =SATA_OOB_MODE ;sas_notify_phy_event (&phy->sas_phy,PHYE_OOB_DONE ,GFP_ATOMIC );spin_lock_irqsave (&phy->sas_phy.frame_rcvd_lock, flags); -memcpy (phy->frame_rcvd, ((u8 *)&pPayload->sata_fis -4 ), +memcpy (phy->frame_rcvd, &pPayload->sata_fis,sizeof (struct dev_to_host_fis )); phy->frame_rcvd_size =sizeof (struct dev_to_host_fis ); phy->identify.target_port_protocols =SAS_PROTOCOL_SATA ;
drivers/scsi/pm8001/pm80xx_hwi.h +3 -97
119 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/1756 staging: iio: adc: ad7816: Fix DMA safety issues in SPI transfers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdelnasser Hussein <[email protected]>
[ Upstream commit 69fa76f0af3414cc189c3b0b807cb59e327ecc00 ]
The SPI operations in this driver are not DMA safe:
1. spi_read() uses a stack-allocated buffer.
2. spi_write() in ad7816_spi_read() uses a struct member that shares a cacheline with other variables.
3. spi_write() in ad7816_spi_write() passes a stack parameter by reference.
Fix these violations by replacing all spi_read() and spi_write() calls with spi_write_then_read(). This safely handles DMA by internally allocating a bounce buffer for the transfers, avoiding cacheline sharing issues without needing dedicated aligned buffers. This implicitly corrects the size argument in read to sizeof(buf).
--- drivers/staging/iio/adc/ad7816.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7816.c +3 -3
@@ -69,7 +69,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)gpiod_set_value (chip->rdwr_pin,1 );gpiod_set_value (chip->rdwr_pin,0 ); - ret =spi_write (spi_dev, &chip->channel_id,sizeof (chip->channel_id)); + ret =spi_write_then_read (spi_dev, &chip->channel_id,sizeof (chip->channel_id),NULL ,0 );if (ret <0 ) {dev_err (&spi_dev->dev,"SPI channel setting error\n" );return ret;
@@ -91,7 +91,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)gpiod_set_value (chip->rdwr_pin,0 );gpiod_set_value (chip->rdwr_pin,1 ); - ret =spi_read (spi_dev, &buf,sizeof (*data)); + ret =spi_write_then_read (spi_dev,NULL ,0 , &buf,sizeof (buf));if (ret <0 ) {dev_err (&spi_dev->dev,"SPI data read error\n" );return ret;
@@ -109,7 +109,7 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data)gpiod_set_value (chip->rdwr_pin,1 );gpiod_set_value (chip->rdwr_pin,0 ); - ret =spi_write (spi_dev, &data,sizeof (data)); + ret =spi_write_then_read (spi_dev, &data,sizeof (data),NULL ,0 );if (ret <0 )dev_err (&spi_dev->dev,"SPI oti data write error\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/1756 md/raid10: fix missing wakeup in wait_barrier_nolock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit f00eb0ff45793383d5a62db2d2aea63ada0ccdbd ]
Fuzz testing triggered a hung raid10d thread:
INFO: task md0_raid10 blocked for more than 120 seconds. Call Trace: raid10d md_thread kthread
wait_barrier_nolock() speculatively increments nr_pending. If a concurrent writer changes resync_lock's sequence, it rolls the count back with atomic_dec_and_test(). The rollback currently wakes wait_barrier only when nr_pending reaches zero.
freeze_array() can be waiting for nr_pending == nr_queued + extra while array_freeze_pending is set. If the rollback changes nr_pending from 2 to 1, the condition becomes true but no wakeup is sent, leaving raid10d blocked indefinitely.
Also wake wait_barrier when array_freeze_pending is set, matching allow_barrier().
--- drivers/md/raid10.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid10.c +2 -1
@@ -993,7 +993,8 @@ static bool wait_barrier_nolock(struct r10conf *conf)if (!read_seqretry (&conf->resync_lock, seq))return true; -if (atomic_dec_and_test (&conf->nr_pending)) +if (atomic_dec_and_test (&conf->nr_pending) || +READ_ONCE (conf->array_freeze_pending))wake_up_barrier (conf);return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/1756 md: reject v0.90 arrays with too many devices
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 1a33a379e67853d6d778e6e80b214bdf1208f6f8 ]
The v0.90 superblock has room for MD_SB_DISKS device descriptors, but super_90_load() only rejects nonpositive raid_disks values. A crafted superblock can therefore copy a larger value into mddev->raid_disks. When metadata is next updated, super_90_sync() walks sb->disks[] up to that count and reads and writes beyond the 4 KiB superblock buffer.
A checksum-valid RAID1 member advertising 64 devices can be assembled by mdadm --incremental --run. The first write to the array then produces out-of-bounds writes from super_90_sync() under KASAN.
Reject device counts that cannot be represented by the v0.90 format while loading the superblock.
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -1263,7 +1263,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor goto abort; } -if (sb->raid_disks <=0 ) +if (sb->raid_disks <=0 || sb->raid_disks >MD_SB_DISKS ) goto abort;if (md_csum_fold (calc_sb_csum (sb)) !=md_csum_fold (sb->sb_csum)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/1756 md/raid5: dont BUG() on an inconsistent reshape state from the superblock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 0669c7dbd1d375f279e607a24addc2f1dae2d4f3 ]
raid5_run() branches on mddev->reshape_position. When it is MaxSector -- no reshape in progress -- the else branch asserts that nothing else describes one:
BUG_ON(mddev->level != mddev->new_level); BUG_ON(mddev->layout != mddev->new_layout); BUG_ON(mddev->chunk_sectors != mddev->new_chunk_sectors); BUG_ON(mddev->delta_disks != 0);
Nothing enforces that invariant. Both superblock validators copy the reshape fields straight off disk without cross-checking them against each other: super_1_validate() takes reshape_position, delta_disks, new_level, new_layout and new_chunk from the superblock whenever MD_FEATURE_RESHAPE_ACTIVE is set, and super_90_validate() does the same for minor version 91. A superblock that sets the reshape feature while leaving reshape_position at the MaxSector sentinel therefore reaches the else branch with a non-zero delta_disks, and assembling the array takes the machine down:
kernel BUG at drivers/md/raid5.c:8117!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:raid5_run+0x11a7/0x1670 drivers/md/raid5.c:8117 Call Trace: md_run+0xc2f/0x2510 drivers/md/md.c:6779 do_md_run+0x36/0x660 drivers/md/md.c:6880 array_state_store+0x9c5/0xcf0 drivers/md/md.c:4765 md_attr_store+0x1c5/0x330 drivers/md/md.c:6158 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345
This is reachable by anyone who can present an md superblock, so BUG() is the wrong response. Refuse to start the array instead, the way the reshape_position != MaxSector branch a few lines above already refuses a reshape it cannot resume. Nothing has been allocated at this point -- the journal-and-bitmap check just above returns -EINVAL the same way -- so there is nothing to unwind.
--- drivers/md/raid5.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/md/raid5.c +11 -5
@@ -7959,11 +7959,17 @@ static int raid5_run(struct mddev *mddev) }pr_debug ("md/raid:%s: reshape will continue\n" ,mdname (mddev));/* OK, we should be able to continue; */ - }else { -BUG_ON (mddev->level != mddev->new_level); -BUG_ON (mddev->layout != mddev->new_layout); -BUG_ON (mddev->chunk_sectors != mddev->new_chunk_sectors); -BUG_ON (mddev->delta_disks !=0 ); + }else if (mddev->level != mddev->new_level || + mddev->layout != mddev->new_layout || + mddev->chunk_sectors != mddev->new_chunk_sectors || + mddev->delta_disks !=0 ) { +/* No reshape is in progress, but the array describes one. +* The superblock validators do not cross-check these against +* reshape_position, so this is reachable from disk. +*/ +pr_warn ("md/raid:%s: inconsistent reshape state - aborting.\n" , +mdname (mddev)); +return -EINVAL ; } if (test_bit(MD_HAS_JOURNAL, &mddev->flags) &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/1756 md/raid5: reject raid4/5 arrays with too few disks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Cheng <[email protected]>
[ Upstream commit 0d9bbbb6fafa22659ccd4d7ab94329a43c2632d0 ]
raid4 and raid5 require at least two disks, while raid6 requires at least four disks. setup_conf() only rejects raid6 arrays with fewer than four disks. As a result, an invalid raid4 or raid5 array can be assembled with no data disks and later reach raid5_set_limits().
Reject such arrays before the r5conf is created. This prevents the invalid geometry from reaching queue limit setup, where roundup_pow_of_two() can be called with a zero stripe size.
--- drivers/md/raid5.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/raid5.c +5 -3
@@ -7514,9 +7514,11 @@ static struct r5conf *setup_conf(struct mddev *mddev) mdname(mddev), mddev->new_layout);return ERR_PTR (-EIO ); } -if (mddev->new_level ==6 && mddev->raid_disks <4 ) { -pr_warn ("md/raid:%s: not enough configured devices (%d, minimum 4)\n" , -mdname (mddev), mddev->raid_disks); +if ((mddev->new_level !=6 && mddev->raid_disks <2 ) || + (mddev->new_level ==6 && mddev->raid_disks <4 )) { +pr_warn ("md/raid:%s: not enough configured devices (%d, minimum %d)\n" , +mdname (mddev), mddev->raid_disks, + mddev->new_level ==6 ?4 :2 );return ERR_PTR (-EINVAL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/1756 md/raid5: setup_conf: Fix null-ptr-def in error handling path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit eba5f518701b1c7f2d883504f89c41611bd2de46 ]
For raid5 setup_conf, if an error(eg. bioset_init fails) happens before 'conf->mddev = mddev', following error handling path could trigger a null-ptr-def problem:
free_conf
log_exit
raid5_has_ppl
test_bit(MD_HAS_PPL, &conf->mddev->flags) // conf->mddev is NULL !
Fix it by initializing conf->mddev in advance.
--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
@@ -7534,6 +7534,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)if (conf ==NULL ) goto abort; + conf->mddev = mddev;#if PAGE_SIZE !=DEFAULT_STRIPE_SIZE conf->stripe_size =DEFAULT_STRIPE_SIZE ; conf->stripe_shift =ilog2 (DEFAULT_STRIPE_SIZE ) -9 ;
@@ -7607,7 +7608,6 @@ static struct r5conf *setup_conf(struct mddev *mddev) ret =bioset_init (&conf->bio_split,BIO_POOL_SIZE ,0 ,0 );if (ret) goto abort; - conf->mddev = mddev; ret = -ENOMEM ; conf->stripe_hashtbl =kzalloc (PAGE_SIZE ,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/1756 md/raid5: reject a per-device size smaller than one chunk
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit 370ca0760b18c64592a258bcb057ff0a2531aabf ]
Both raid5_run() and raid5_resize() align the per-device size down to a whole multiple of the chunk size:
mddev->dev_sectors &= ~(chunk_sectors - 1);
Neither checks the result, so a size smaller than one chunk silently becomes zero.
In raid5_run() that is harmless: the array size is derived from the same zero, so the disk just ends up with no capacity.
In raid5_resize() it leaves the array inconsistent -- mddev->dev_sectors becomes zero, while mddev->array_sectors and the gendisk capacity keep the previous. A later raid4/raid5 -> raid0 takeover copies the zero into every rdev->sectors (raid0_takeover_raid45()), so create_strip_zones() builds a strip zone table whose zone_end is zero. Any read then passes bio_check_eod() against the stale capacity and hits the BUG() in find_zone():
kernel BUG at drivers/md/raid0.c:318!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI Call Trace: raid0_make_request md_handle_request submit_bio_noacct_nocheck block_read_full_folio read_part_sector bdev_disk_changed bdev_open
Reject a size smaller than one chunk in both functions, so that a running raid4/raid5 array always has mddev->dev_sectors >= one chunk.
The check is done where the value takes effect, not where it is assigned. mddev->dev_sectors is written from several places, and none of them can tell whether the value is usable: the chunk size may still change later. raid5_run() and raid5_resize() are where every input is final, so one check in each covers them all.
--- drivers/md/raid5.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/md/raid5.c +8 -0
@@ -8060,6 +8060,12 @@ static int raid5_run(struct mddev *mddev)/* device size must be a multiple of chunk size */ mddev->dev_sectors &= ~((sector_t )mddev->chunk_sectors -1 ); +if (!mddev->dev_sectors) { +pr_warn ("md/raid:%s: device size is smaller than one chunk\n" , +mdname (mddev)); + ret = -EINVAL ; + goto abort; + } mddev->resync_max_sectors = mddev->dev_sectors; if (mddev->degraded > dirty_parity_disks &&
@@ -8393,6 +8399,8 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)if (raid5_has_log (conf) ||raid5_has_ppl (conf))return -EINVAL ; sectors &= ~((sector_t )conf->chunk_sectors -1 ); +if (!sectors) +return -EINVAL ; newsize =raid5_size (mddev, sectors, mddev->raid_disks);if (mddev->external_size && mddev->array_sectors > newsize)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/1756 clk: si521xx: correct the SI52147 OF output enable map
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 7a4cc47d715f08309089d40b8c29fb0ba79917db ]
The SI52147 data sheet assigns DIFF0 through DIFF3 output-enable bits to 0x17 in control register 1. The OF match data uses 0x15, leaving the DIFF2 bit out of the map, while the I2C ID table already uses the documented value.
Use 0x17 for the SI52147 OF entry so both enumeration paths expose the documented outputs.
--- drivers/clk/clk-si521xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-si521xx.c +1 -1
@@ -373,7 +373,7 @@ MODULE_DEVICE_TABLE(i2c, si521xx_id);static const struct of_device_id clk_si521xx_of_match[] = { { .compatible ="skyworks,si52144" , .data = (void *)SI521XX_OE_MAP (0x5 ,0xc0 ) }, { .compatible ="skyworks,si52146" , .data = (void *)SI521XX_OE_MAP (0x15 ,0xe0 ) }, - { .compatible ="skyworks,si52147" , .data = (void *)SI521XX_OE_MAP (0x15 ,0xf8 ) }, + { .compatible ="skyworks,si52147" , .data = (void *)SI521XX_OE_MAP (0x17 ,0xf8 ) }, { } };MODULE_DEVICE_TABLE (of, clk_si521xx_of_match);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/1756 clk: milbeaut: Return divider update timeouts
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 92d0998090d1716ee6b47174c10eb9415a12fca8 ]
m10v_clk_divider_set_rate() logs when the hardware does not clear its write-valid request, but still returns success to the clock framework. It also uses the sleeping poll helper while holding the divider spinlock.
Use the atomic poll helper under the lock and return its timeout so the rate change is not reported as successful before the hardware accepts it.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/clk/clk-milbeaut.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/clk/clk-milbeaut.c +6 -4
@@ -411,8 +411,8 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) {struct m10v_clk_divider *divider =to_m10v_div (hw); -int value;unsigned long flags =0 ; +int value, ret =0 ;u32 val;u32 write_en =BIT (divider->width -1 );
@@ -434,8 +434,10 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,if (divider->write_valid_reg) {writel (M10V_DCHREQ , divider->write_valid_reg); -if (readl_poll_timeout (divider->write_valid_reg, val, - !val,M10V_UPOLL_RATE ,M10V_UTIMEOUT )) + ret =readl_poll_timeout_atomic (divider->write_valid_reg, val, + !val,M10V_UPOLL_RATE , +M10V_UTIMEOUT ); +if (ret)pr_err ("%s:%s couldn't stabilize\n" , __func__,clk_hw_get_name (hw)); }
@@ -445,7 +447,7 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,else __release (divider->lock); -return 0 ; +return ret; }static const struct clk_ops m10v_clk_divider_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/1756 drm/amd/pm: bound SCLK FCW range entries to the table size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Mishal <[email protected]>
[ Upstream commit f35aa5c77f5fca20fc269d6221df19c7b96704a5 ]
atomctrl_get_smc_sclk_range_table() copies ucSclkEntryNum entries from the VBIOS SMU_Info table into pp_atom_ctrl_sclk_range_table. Both the source (asSclkFcwRangeEntry[]) and destination (table->entry[]) arrays are fixed at MAX_SCLK_RANGE (8) entries, but ucSclkEntryNum is an unchecked u8 read straight from the VBIOS, so it can be up to 255. The destination is stack-allocated in both callers (polaris10_get_sclk_range_table(), vegam_get_sclk_range_table()), so a count above 8 overflows a stack buffer, not just a heap read.
Reject counts above MAX_SCLK_RANGE rather than clamping to it. Only one version of this VBIOS struct (ATOM_SMU_INFO_V2_1) has ever existed, so a count above 8 corresponds to no legitimate table format and means either a corrupted or a tampered VBIOS.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +3 -0
@@ -1453,6 +1453,9 @@ int atomctrl_get_smc_sclk_range_table(struct pp_hwmgr *hwmgr, struct pp_atom_ctrif (!psmu_info)return -EINVAL ; +if (psmu_info->ucSclkEntryNum >MAX_SCLK_RANGE ) +return -EINVAL ; +for (i =0 ; i < psmu_info->ucSclkEntryNum; i++) { table->entry[i].ucVco_setting = psmu_info->asSclkFcwRangeEntry[i].ucVco_setting; table->entry[i].ucPostdiv = psmu_info->asSclkFcwRangeEntry[i].ucPostdiv;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/1756 drm/amdgpu: Add vbios build number interface
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <[email protected]>
[ Upstream commit d6fa8026617896c23cb165f09f1c1d32fe22a3df ]
Fetch VBIOS build number from atom rom image. Add a sysfs interface to read the build number.
Stable-dep-of: aee05c455ad3 ("drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 33 ++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/atom.c | 22 +++++++++++++ drivers/gpu/drm/amd/amdgpu/atom.h | 2 ++ 3 files changed, 54 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +30 -3
@@ -1797,16 +1797,43 @@ static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,return sysfs_emit (buf,"%s\n" , ctx->vbios_pn); } +static ssize_t amdgpu_atombios_get_vbios_build (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev =drm_to_adev (ddev); +struct atom_context *ctx = adev->mode_info.atom_context; + +return sysfs_emit (buf,"%s\n" , ctx->build_num); +} + static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, NULL); +static DEVICE_ATTR(vbios_build, 0444, amdgpu_atombios_get_vbios_build, NULL);static struct attribute *amdgpu_vbios_version_attrs[] = { - &dev_attr_vbios_version.attr, -NULL + &dev_attr_vbios_version.attr, &dev_attr_vbios_build.attr,NULL }; +static umode_t amdgpu_vbios_version_attrs_is_visible (struct kobject *kobj, +struct attribute *attr, +int index) +{ +struct device *dev =kobj_to_dev (kobj); +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev =drm_to_adev (ddev); +struct atom_context *ctx = adev->mode_info.atom_context; + +if (attr == &dev_attr_vbios_build.attr && !strlen (ctx->build_num)) +return 0 ; + +return attr->mode; +} +const struct attribute_group amdgpu_vbios_version_attr_group = { - .attrs = amdgpu_vbios_version_attrs + .attrs = amdgpu_vbios_version_attrs, + .is_visible = amdgpu_vbios_version_attrs_is_visible, };int amdgpu_atombios_sysfs_init (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/atom.c +22 -0
@@ -1497,6 +1497,27 @@ static void atom_get_vbios_version(struct atom_context *ctx) } } +static void atom_get_vbios_build (struct atom_context *ctx) +{ +unsigned char *atom_rom_hdr; +unsigned char *str; +uint16_t base; + + base =CU16 (ATOM_ROM_TABLE_PTR ); + atom_rom_hdr =CSTR (base); + + str =CSTR (CU16 (base +ATOM_ROM_CFG_PTR )); +/* Skip config string */ +while (str < atom_rom_hdr && *str++) + ; +/* Skip change list string */ +while (str < atom_rom_hdr && *str++) + ; + +if ((str +STRLEN_NORMAL ) < atom_rom_hdr) +strscpy (ctx->build_num, str,STRLEN_NORMAL ); +} +struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios) {int base;
@@ -1557,6 +1578,7 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)atom_get_vbios_pn (ctx);atom_get_vbios_date (ctx);atom_get_vbios_version (ctx); +atom_get_vbios_build (ctx);return ctx; }
drivers/gpu/drm/amd/amdgpu/atom.h +2 -0
@@ -37,6 +37,7 @@ struct drm_device;#define ATOM_ROM_MAGIC "ATOM"#define ATOM_ROM_MAGIC_PTR 4 +#define ATOM_ROM_CFG_PTR 0xC#define ATOM_ROM_MSG_PTR 0x10#define ATOM_ROM_CMD_PTR 0x1E#define ATOM_ROM_DATA_PTR 0x20
@@ -151,6 +152,7 @@ struct atom_context {uint32_t version;uint8_t vbios_ver_str[STRLEN_NORMAL ];uint8_t date[STRLEN_NORMAL ]; +uint8_t build_num[STRLEN_NORMAL ]; };extern int amdgpu_atom_debug;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 444/1756 drm/amd: Add correct prefix for VBIOS message
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello (AMD) <[email protected]>
[ Upstream commit e6c7ebeaba4080562e71a59a788ac90b41e09240 ]
It's not obvious which GPU the ATOM BIOS message goes with. Use drm_info() to show the correct one.
Stable-dep-of: aee05c455ad3 ("drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters")
--- drivers/gpu/drm/amd/amdgpu/atom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/atom.c +1 -1
@@ -1462,7 +1462,7 @@ static void atom_get_vbios_pn(struct atom_context *ctx) ctx->vbios_pn[count] =0 ; } -pr_info ("ATOM BIOS: %s\n" , ctx->vbios_pn); +drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , ctx->vbios_pn); }static void atom_get_vbios_version (struct atom_context *ctx)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/1756 drm/amdgpu: Print full vbios info
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <[email protected]>
[ Upstream commit 4fd7b724a87a4051401ee2ed64c26c9249582040 ]
Add build number, version and date to the existing part number print.
Example:
[drm] ATOM BIOS: 113-PN000108-103, build: 00159017, ver: 022.040.003.043.000001, 2025/07/27
Stable-dep-of: aee05c455ad3 ("drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters")
--- drivers/gpu/drm/amd/amdgpu/atom.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +26 -2
@@ -1461,8 +1461,6 @@ static void atom_get_vbios_pn(struct atom_context *ctx) ctx->vbios_pn[count] =0 ; } - -drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , ctx->vbios_pn); }static void atom_get_vbios_version (struct atom_context *ctx)
@@ -1518,6 +1516,30 @@ static void atom_get_vbios_build(struct atom_context *ctx)strscpy (ctx->build_num, str,STRLEN_NORMAL ); } +static inline void atom_print_vbios_info (struct atom_context *ctx) +{ +char vbios_info[256 ]; +int off =0 ; + +if (ctx->vbios_pn[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%s" , ctx->vbios_pn); +if (ctx->build_num[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%sbuild: %s" , off ?", " :"" , + ctx->build_num); +if (ctx->vbios_ver_str[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%sver: %s" , off ?", " :"" , + ctx->vbios_ver_str); +if (ctx->date[0 ]) + off +=scnprintf (vbios_info + off,sizeof (vbios_info) - off, +"%s%.10s" , off ?", " :"" , + ctx->date); +if (off) +drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , vbios_info); +} +struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios) {int base;
@@ -1580,6 +1602,8 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)atom_get_vbios_version (ctx);atom_get_vbios_build (ctx); +atom_print_vbios_info (ctx); +return ctx; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/1756 drm/amdgpu: bounds check ATOM IIO table parsing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <[email protected]>
[ Upstream commit be88697602238c3dcb47bbc2db1eef923f63e78b ]
atom_index_iio() parsed the IIO bytecode without bounds checks, allowing out-of-bounds reads on a malformed VBIOS. Pass the BIOS size into amdgpu_atom_parse() and bound the parse loops by it.
Stable-dep-of: aee05c455ad3 ("drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 +- drivers/gpu/drm/amd/amdgpu/atom.c | 25 ++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/atom.h | 3 ++- 3 files changed, 23 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +1 -1
@@ -1893,7 +1893,7 @@ int amdgpu_atombios_init(struct amdgpu_device *adev) atom_card_info->pll_read = cail_pll_read; atom_card_info->pll_write = cail_pll_write; - adev->mode_info.atom_context =amdgpu_atom_parse (atom_card_info, adev->bios); + adev->mode_info.atom_context =amdgpu_atom_parse (atom_card_info, adev->bios, adev->bios_size);if (!adev->mode_info.atom_context) {amdgpu_atombios_fini (adev);return -ENOMEM ;
drivers/gpu/drm/amd/amdgpu/atom.c +20 -5
@@ -1316,11 +1316,25 @@ static void atom_index_iio(struct atom_context *ctx, int base) ctx->iio =kzalloc (2 *256 ,GFP_KERNEL );if (!ctx->iio)return ; -while (CU8 (base) ==ATOM_IIO_START ) { - ctx->iio[CU8 (base +1 )] = base +2 ; +while (base +1 < ctx->bios_size &&CU8 (base) ==ATOM_IIO_START ) { +uint8_t index =CU8 (base +1 ); +int start = base +2 ; base +=2 ; -while (CU8 (base) !=ATOM_IIO_END ) - base += atom_iio_len[CU8 (base)]; +while (base < ctx->bios_size &&CU8 (base) !=ATOM_IIO_END ) { +uint8_t op =CU8 (base); + +/* +* Unknown opcode: its length is unknown so the byte +* stream cannot be resynced reliably. +*/ +if (op >=ARRAY_SIZE (atom_iio_len)) +return ; + base += atom_iio_len[op]; + } +if (base >= ctx->bios_size) +return ; +/* Only index well-formed methods, others stay 0 */ + ctx->iio[index] = start; base +=3 ; } }
@@ -1540,7 +1554,7 @@ static inline void atom_print_vbios_info(struct atom_context *ctx)drm_info (ctx->card->dev,"ATOM BIOS: %s\n" , vbios_info); } -struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios) +struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios,uint32_t bios_size) {int base; struct atom_context *ctx =
@@ -1554,6 +1568,7 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios) ctx->card = card; ctx->bios = bios; + ctx->bios_size = bios_size;if (CU16 (0 ) !=ATOM_BIOS_MAGIC ) {pr_info ("Invalid BIOS magic\n" );
drivers/gpu/drm/amd/amdgpu/atom.h +2 -1
@@ -133,6 +133,7 @@ struct atom_context {struct card_info *card;struct mutex mutex;void *bios; +uint32_t bios_size;uint32_t cmd_table, data_table;uint16_t *iio;
@@ -157,7 +158,7 @@ struct atom_context {extern int amdgpu_atom_debug; -struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios); +struct atom_context *amdgpu_atom_parse (struct card_info *card,void *bios,uint32_t bios_size);int amdgpu_atom_execute_table (struct atom_context *ctx,int index,uint32_t *params,int params_size);int amdgpu_atom_asic_init (struct atom_context *ctx);void amdgpu_atom_destroy (struct atom_context *ctx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/1756 drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Mishal <[email protected]>
[ Upstream commit aee05c455ad3e72df9a0591baf0b60da518800f3 ]
atom_get_vbios_date(), atom_get_vbios_pn(), atom_get_vbios_version() and atom_get_vbios_build() all walk the BIOS image using offsets and counts taken from the image itself, checked only against each other and never against ctx->bios_size:
- atom_get_vbios_date() reads 14 bytes at a fixed offset that check_atom_bios()'s minimum size (0x49) does not cover.
- atom_get_vbios_pn() dereferences an image-supplied u16 string offset unchecked, then walks and copies from it with only a length cap, not an image cap.
- atom_get_vbios_version() takes its search bounds from image u16s; atom_find_str_in_rom() already clamps the search itself, but the match is then advanced by a fixed 18 bytes and STRLEN_NORMAL bytes are copied from there with no check that this still lands inside the image.
- atom_get_vbios_build() walks from an image-supplied config-string offset toward the ROM header; a config offset at or past the header makes the pointer difference negative, wrapping through the u16 'len' and passing strscpy() a bound far larger than the 32-byte destination.
Bound each getter's reads, walks and copies to ctx->bios_size, falling back to an empty string on a malformed image.
--- drivers/gpu/drm/amd/amdgpu/atom.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +24 -5
@@ -1394,6 +1394,11 @@ static void atom_get_vbios_date(struct atom_context *ctx) p_rom = ctx->bios; +if (ctx->bios_size <OFFSET_TO_VBIOS_DATE +14 ) { + ctx->date[0 ] ='\0' ; +return ; + } + date_in_rom = p_rom +OFFSET_TO_VBIOS_DATE ; ctx->date[0 ] ='2' ;
@@ -1457,17 +1462,24 @@ static void atom_get_vbios_pn(struct atom_context *ctx) vbios_str = p_rom +OFFSET_TO_VBIOS_PART_NUMBER ; } -if (*vbios_str ==0 ) { +if (vbios_str >= p_rom + ctx->bios_size) + vbios_str =NULL ; + +if (vbios_str ==NULL || *vbios_str ==0 ) { vbios_str =atom_find_str_in_rom (ctx,BIOS_ATOM_PREFIX ,3 ,1024 ,64 );if (vbios_str ==NULL ) vbios_str +=sizeof (BIOS_ATOM_PREFIX ) -1 ; +if (vbios_str >= p_rom + ctx->bios_size) + vbios_str =NULL ; }if (vbios_str !=NULL && *vbios_str ==0 ) vbios_str++;if (vbios_str !=NULL ) { count =0 ; -while ((count <BIOS_STRING_LENGTH ) && vbios_str[count] >=' ' && +while ((count <BIOS_STRING_LENGTH ) && + vbios_str + count < p_rom + ctx->bios_size && + vbios_str[count] >=' ' && vbios_str[count] <='z' ) { ctx->vbios_pn[count] = vbios_str[count]; count++;
@@ -1500,9 +1512,10 @@ static void atom_get_vbios_version(struct atom_context *ctx)/* find anchor ATOMBIOSBK-AMD */ vbios_ver =atom_find_str_in_rom (ctx,BIOS_VERSION_PREFIX , start, end,64 ); -if (vbios_ver !=NULL ) { -/* skip ATOMBIOSBK-AMD VER */ - vbios_ver +=18 ; +if (vbios_ver !=NULL ) + vbios_ver +=18 ;/* skip ATOMBIOSBK-AMD VER */ + +if (vbios_ver !=NULL && vbios_ver +STRLEN_NORMAL <= p_rom + ctx->bios_size) {memcpy (ctx->vbios_ver_str, vbios_ver,STRLEN_NORMAL ); }else { ctx->vbios_ver_str[0 ] ='\0' ;
@@ -1518,7 +1531,13 @@ static void atom_get_vbios_build(struct atom_context *ctx) base =CU16 (ATOM_ROM_TABLE_PTR ); atom_rom_hdr =CSTR (base); +if ((uint32_t )base +ATOM_ROM_CFG_PTR +sizeof (uint16_t ) > ctx->bios_size) +return ; + str =CSTR (CU16 (base +ATOM_ROM_CFG_PTR )); +if (str >= atom_rom_hdr) +return ; +/* Skip config string */ while (str < atom_rom_hdr && *str++) ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/1756 ata: sata_dwc_460ex: Dont enable interrupt if libATA core registration fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Borisov <[email protected]>
[ Upstream commit e137035fcd66cb454c479bb989968561bbc60341 ]
Recent 4bbc16a353a9 commit changed the timing when interrupts are enabled. However it didn't account for the libATA registration step. So it's possible that interrupts are enabled when the device is not registered with libATA core.
Resolve the issue by failing the entire registration process in case of failure to register with libATA.
--- drivers/ata/sata_dwc_460ex.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/ata/sata_dwc_460ex.c +4 -1
@@ -1184,11 +1184,14 @@ static int sata_dwc_probe(struct platform_device *ofdev)* error_handler() to execute a dummy Softreset EH session */ err =ata_host_activate (host, irq, sata_dwc_isr,0 , &sata_dwc_sht); -if (err) +if (err) {dev_err (dev,"failed to activate host" ); + goto error_out; + }/* Enable SATA Interrupts */ sata_dwc_enable_interrupts (hsdev); +return 0 ; error_out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/1756 libbpf: Reject local struct_ops bitfields before data access
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingpei CAO <[email protected]>
[ Upstream commit 961b8946acb482b6d7a39c266d623e5f9c4e873f ]
A local struct_ops type can contain a bitfield absent from the corresponding kernel BTF type. bpf_map__init_kern_struct_ops() checks whether data for an absent local member is zero.
For a bitfield, member->offset contains the bit offset and field width. bpf_map__init_kern_struct_ops() used the encoded value to calculate the member data pointer before rejecting the bitfield. The zero-data check could therefore read outside st_ops->data and crash libbpf.
Reject local bitfields before calculating the member data pointer. Keep the existing rejection for bitfields in the kernel type.
--- tools/lib/bpf/libbpf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +7 -2
@@ -1176,6 +1176,12 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map)const char *mname; mname =btf__name_by_offset (btf, member->name_off); +if (btf_member_bitfield_size (type, i)) { +pr_warn ("struct_ops init_kern %s: local bitfield %s is not supported\n" , + map->name, mname); +return -ENOTSUP ; + } + moff = member->offset /8 ; mdata = data + moff; msize =btf__resolve_size (btf, member->type);
@@ -1212,8 +1218,7 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map) } kern_member_idx = kern_member -btf_members (kern_type); -if (btf_member_bitfield_size (type, i) || -btf_member_bitfield_size (kern_type, kern_member_idx)) { +if (btf_member_bitfield_size (kern_type, kern_member_idx)) {pr_warn ("struct_ops init_kern %s: bitfield %s is not supported\n" , map->name, mname);return -ENOTSUP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/1756 Revert "rcu/nocb: Fix rcuog wake-up from offline softirq"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
[ Upstream commit b95d15980a0f2727a421392ebb50fc6338e43b02 ]
This reverts commit f7345ccc62a4b880cf76458db5f320725f28e400.
swake_up_one_online() has been removed because hrtimers can now assign a proper online target to hrtimers queued from offline CPUs. Therefore remove the related hackery.
Stable-dep-of: 4c714f015d9e ("rcu: fix shrink budget underflow in lazy_rcu_shrink_scan")
--- kernel/rcu/tree_nocb.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
kernel/rcu/tree_nocb.h +1 -7
@@ -554,19 +554,13 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,rcu_nocb_unlock (rdp);wake_nocb_gp_defer (rdp,RCU_NOCB_WAKE_LAZY ,TPS ("WakeLazy" )); - }else if (!irqs_disabled_flags (flags) &&cpu_online (rdp->cpu)) { + }else if (!irqs_disabled_flags (flags)) {/* ... if queue was empty ... */ rcu_nocb_unlock (rdp);wake_nocb_gp (rdp, false);trace_rcu_nocb_wake (rcu_state.name, rdp->cpu,TPS ("WakeEmpty" )); }else { -/* -* Don't do the wake-up upfront on fragile paths. -* Also offline CPUs can't call swake_up_one_online() from -* (soft-)IRQs. Rely on the final deferred wake-up from -* rcutree_report_cpu_dead() -*/ rcu_nocb_unlock (rdp);wake_nocb_gp_defer (rdp,RCU_NOCB_WAKE ,TPS ("WakeEmptyIsDeferred" ));
Signature · 1 line
2.53.0
Re: [PATCH 6.12 0450/1756] Revert "rcu/nocb: Fix rcuog wake-up from offline softirq"
Hi Greg/Sasha,
Quoted 30 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
[ Upstream commit
b95d15980a0f2727a421392ebb50fc6338e43b02]This reverts commit
f7345ccc62a4b880cf76458db5f320725f28e400.
swake_up_one_online()has been removed because hrtimers can now assign a proper online target to hrtimers queued from offline CPUs. Therefore remove the related hackery.Reviewed-by Usama Arif <[email protected]>Reviewed-by Joel Fernandes <[email protected]>Signed-off-by Frederic Weisbecker <[email protected]>Signed-off-by Joel Fernandes <[email protected]>Stable-dep-of:
4c714f015d9e("rcu: fix shrink budget underflow inlazy_rcu_shrink_scan")Signed-off-by Sasha Levin <[email protected]>--- kernel/rcu/tree_nocb.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)kernel/rcu/tree_nocb.h +0
-0
kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 557
Quoted 5 lines
kernel/rcu/tree_nocb.h +1
-1@@ -554,19 +554,13 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,rcu_nocb_unlock (rdp);wake_nocb_gp_defer (rdp,RCU_NOCB_WAKE_LAZY ,TPS ("WakeLazy" )); - }else if (!irqs_disabled_flags (flags) &&cpu_online (rdp->cpu)) { + }else if (!irqs_disabled_flags (flags)) {
I ran an AI-assisted source review of 6.12.y commit and the finding looks correct to me.
Verdict: lets skip this until we have a reprequisite
This revert removes the offline-CPU guard:
- } else if (!irqs_disabled_flags(flags) && cpu_online(rdp->cpu)) {
+ } else if (!irqs_disabled_flags(flags)) {
However, the destination still wakes the NOCB GP thread through:
swake_up_one_online(&rdp_gp->nocb_gp_wq);
On an offline CPU, that helper calls:
smp_call_function_single(target, swake_up_one_online_ipi,
wqh, 0);An offline softirq can therefore reach smp_call_function_single(), which contains:
WARN_ON_ONCE(!in_task());
This is the path that f7345ccc62a4 originally guarded against. The existing hrtimer changes do not remove this IPI call.
Upstream b95d15980a0f follows 0999f6156013 ("rcu: Remove swake_up_one_online() bandaid"), which changes the NOCB wake to:
swake_up_one(&rdp_gp->nocb_gp_wq);
Could we include 0999f6156013, or retain the offline-CPU guard until the IPI helper is removed?
I think we should drop this commit until then.
Thanks,
Harshit
Quoted 15 lines
kernel/rcu/tree_nocb.h +0
-6/* ... if queue was empty ... */ rcu_nocb_unlock (rdp);wake_nocb_gp (rdp, false);trace_rcu_nocb_wake (rcu_state.name, rdp->cpu,TPS ("WakeEmpty" )); }else { -/* -* Don't do the wake-up upfront on fragile paths. -* Also offline CPUs can't call swake_up_one_online() from -* (soft-)IRQs. Rely on the final deferred wake-up from -* rcutree_report_cpu_dead() -*/ rcu_nocb_unlock (rdp);wake_nocb_gp_defer (rdp,RCU_NOCB_WAKE ,TPS ("WakeEmptyIsDeferred" ));
Sasha Levin
maintainerRe: [PATCH 6.12 0450/1756] Revert "rcu/nocb: Fix rcuog wake-up from offline softirq"
Quoted 2 lines
Could we include
0999f6156013, or retain the offline-CPU guard until the IPI helper is removed?
Queued 0999f6156013 ("rcu: Remove swake_up_one_online() bandaid") ahead of the revert for 6.12 and 6.6, thanks.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 451/1756 rcu/nocb: Remove unnecessary WakeOvfIsDeferred wake path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joel Fernandes <[email protected]>
[ Upstream commit d92eca60fea944b2e9272603308a0fde8b6ae447 ]
The WakeOvfIsDeferred code path in __call_rcu_nocb_wake() attempts to wake rcuog when the callback count exceeds qhimark and callbacks aren't done with their GP (newly queued or awaiting GP). However, a lot of testing proves this wake is always redundant or useless.
In the flooding case, rcuog is always waiting for a GP to finish. So waking up the rcuog thread is pointless. The timer wakeup adds overhead, rcuog simply wakes up and goes back to sleep achieving nothing.
This path also adds a full memory barrier, and additional timer expiry modifications unnecessarily.
The root cause is that WakeOvfIsDeferred fires when !rcu_segcblist_ready_cbs() (GP not complete), but waking rcuog cannot accelerate GP completion.
This commit therefore removes this path.
Tested with rcutorture scenarios: TREE01, TREE05, TREE08 (all NOCB configurations) - all pass. Also stress tested using a kernel module that floods call_rcu() to trigger the overload conditions and made the observations confirming the findings.
Stable-dep-of: 4c714f015d9e ("rcu: fix shrink budget underflow in lazy_rcu_shrink_scan")
--- kernel/rcu/tree.c | 2 +- kernel/rcu/tree.h | 3 +-- kernel/rcu/tree_nocb.h | 49 ++++++++++++++---------------------------- 3 files changed, 18 insertions(+), 36 deletions(-)
kernel/rcu/tree.c +1 -1
@@ -4547,7 +4547,7 @@ static void rcu_barrier_entrain(struct rcu_data *rdp) }rcu_nocb_unlock (rdp);if (wake_nocb) -wake_nocb_gp (rdp, false); +wake_nocb_gp (rdp);smp_store_release (&rdp->barrier_seq_snap, gseq); }
kernel/rcu/tree.h +1 -2
@@ -300,7 +300,6 @@ struct rcu_data {#define RCU_NOCB_WAKE_BYPASS 1#define RCU_NOCB_WAKE_LAZY 2#define RCU_NOCB_WAKE 3 -#define RCU_NOCB_WAKE_FORCE 4#define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500))/* For jiffies_till_first_fqs and */
@@ -499,7 +498,7 @@ static void zero_cpu_stall_ticks(struct rcu_data *rdp);static struct swait_queue_head *rcu_nocb_gp_get (struct rcu_node *rnp);static void rcu_nocb_gp_cleanup (struct swait_queue_head *sq);static void rcu_init_one_nocb (struct rcu_node *rnp); -static bool wake_nocb_gp (struct rcu_data *rdp,bool force); +static bool wake_nocb_gp (struct rcu_data *rdp);static bool rcu_nocb_flush_bypass (struct rcu_data *rdp,struct rcu_head *rhp,unsigned long j,bool lazy); static void call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *head,
kernel/rcu/tree_nocb.h +16 -33
139 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/1756 rcu: fix shrink budget underflow in lazy_rcu_shrink_scan
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Longlong Xia <[email protected]>
[ Upstream commit 4c714f015d9ecc37d7a330b31822ccbcaff5ddc9 ]
The lazy RCU shrinker decremented sc->nr_to_scan (unsigned long) and then tested the result with <= 0. When a single CPU's lazy callback count exceeds the remaining budget, the subtraction wraps to a large positive value and the <= 0 comparison, which is equivalent to == 0 for an unsigned type, never fires again. The scan loop then iterates through every nocb CPU instead of honouring the reclaim budget.
Accumulate into count and stop once count >= nr_to_scan.
--- kernel/rcu/tree_nocb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/rcu/tree_nocb.h +1 -2
@@ -1256,9 +1256,8 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)rcu_nocb_try_flush_bypass (rdp, jiffies);rcu_nocb_unlock_irqrestore (rdp, flags);wake_nocb_gp (rdp); - sc->nr_to_scan -= _count; count += _count; -if (sc->nr_to_scan <=0 ) +if (count >= sc->nr_to_scan)break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/1756 PCI: dra7xx: Remove device links to PHY
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: [email protected] <[email protected]>
[ Upstream commit 52cd9bb3772e82d792cb0def3c2a5a9b6bd24ffb ]
This is a full revert of commit 7a4db656a635 ("PCI: dra7xx: Create functional dependency between PCIe and PHY").
The trouble with this is that a PHY consumer driver dereferences fields from struct phy, which will become no longer possible.
Since commit 987351e1ea77 ("phy: core: Add consumer device link support") from 2019, the PHY core also adds a device link to order PHY provider and consumer suspend/resume operations. The reverted functionality is from 2017 and is redundant with the PHY core now.
Stable-dep-of: 768e5d0936d0 ("PCI: dra7xx: Fix clock enable leak on probe failure")
--- drivers/pci/controller/dwc/pci-dra7xx.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +0 -16
@@ -9,7 +9,6 @@#include <linux/clk.h> #include <linux/delay.h> -#include <linux/device.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/irq.h>
@@ -698,7 +697,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)int i;int phy_count;struct phy **phy; -struct device_link **link;void __iomem *base;struct dw_pcie *pci;struct dra7xx_pcie *dra7xx;
@@ -746,10 +744,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)if (!phy)return -ENOMEM ; - link =devm_kcalloc (dev, phy_count,sizeof (*link),GFP_KERNEL ); -if (!link) -return -ENOMEM ; - dra7xx->clk =devm_clk_get_optional (dev,NULL );if (IS_ERR (dra7xx->clk)) return dev_err_probe(dev, PTR_ERR(dra7xx->clk),
@@ -764,12 +758,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) phy[i] =devm_phy_get (dev, name);if (IS_ERR (phy[i]))return PTR_ERR (phy[i]); - - link[i] =device_link_add (dev, &phy[i]->dev,DL_FLAG_STATELESS ); -if (!link[i]) { - ret = -EINVAL ; - goto err_link; - } } dra7xx->base = base;
@@ -871,10 +859,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)pm_runtime_disable (dev);dra7xx_pcie_disable_phy (dra7xx); -err_link: -while (--i >=0 ) -device_link_del (link[i]); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/1756 PCI: dra7xx: Fix clock enable leak on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 768e5d0936d00d663ce2b8c192cc6ab0b61ad461 ]
dra7xx_pcie_probe() enables the optional clock but never disables it when probing fails afterwards.
Switch to devm_clk_get_optional_enabled(), which disables the clock automatically on failure.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +1 -5
@@ -744,15 +744,11 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)if (!phy)return -ENOMEM ; - dra7xx->clk =devm_clk_get_optional (dev,NULL ); + dra7xx->clk =devm_clk_get_optional_enabled (dev,NULL );if (IS_ERR (dra7xx->clk))return dev_err_probe (dev,PTR_ERR (dra7xx->clk),"clock request failed" ); - ret =clk_prepare_enable (dra7xx->clk); -if (ret) -return ret; -for (i =0 ; i < phy_count; i++) {snprintf (name,sizeof (name),"pcie-phy%d" , i); phy[i] =devm_phy_get (dev, name);
Signature · 1 line
2.53.0