Skip to content

Commit 3cc12bb

Browse files
Sibi Sankarsudeep-holla
authored andcommitted
firmware: arm_scmi: Fix NULL pointer dereference during fastchannel init
The scmi_perf_domain_lookup requires the protocol handle to have the private data set, which is yet to happen during the fastchannel init scenario. This results in a NULL pointer dereference. Fix this by using the pre-populated perf_dom_info to pass on the required information instead. | scmi_perf_protocol_init+0x434/0x678 | scmi_get_protocol_instance+0x168/0x29c | scmi_devres_protocol_instance_get+0x50/0xa0 | scmi_devm_protocol_get+0x20/0x50 | scmi_cpufreq_probe+0x34/0xd4 | scmi_dev_probe+0x28/0x3c | really_probe+0x148/0x2ac | __driver_probe_device+0x78/0x12c | driver_probe_device+0x40/0x160 | __device_attach_driver+0xb8/0x134 | bus_for_each_drv+0x80/0xdc | __device_attach+0xa8/0x1b0 | device_initial_probe+0x14/0x20 | bus_probe_device+0xa8/0xac | device_add+0x5cc/0x778 | device_register+0x20/0x30 | __scmi_device_create.part.0+0xec/0x1cc | scmi_device_create+0x180/0x1c4 | scmi_create_protocol_devices+0x4c/0xb0 | scmi_probe+0x660/0x738 | platform_probe+0x68/0xdc | really_probe+0x148/0x2ac | __driver_probe_device+0x78/0x12c | driver_probe_device+0x40/0x160 | __device_attach_driver+0xb8/0x134 | bus_for_each_drv+0x80/0xdc | __device_attach+0xa8/0x1b0 | device_initial_probe+0x14/0x20 | bus_probe_device+0xa8/0xac | deferred_probe_work_func+0x88/0xc0 | process_one_work+0x13c/0x264 | worker_thread+0x32c/0x438 | kthread+0x118/0x11c | ret_from_fork+0x10/0x20 Fixes: 619bc6e ("firmware: arm_scmi: Populate fastchannel info only if set operations are allowed") Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> Link: https://lore.kernel.org/r/20231129065748.19871-2-quic_sibis@quicinc.com Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
1 parent e4e6e8f commit 3cc12bb

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

  • drivers/firmware/arm_scmi

drivers/firmware/arm_scmi/perf.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -759,40 +759,35 @@ static int scmi_perf_level_limits_notify(const struct scmi_protocol_handle *ph,
759759
}
760760

761761
static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph,
762-
u32 domain, struct scmi_fc_info **p_fc)
762+
struct perf_dom_info *dom)
763763
{
764764
struct scmi_fc_info *fc;
765-
struct perf_dom_info *dom;
766-
767-
dom = scmi_perf_domain_lookup(ph, domain);
768-
if (IS_ERR(dom))
769-
return;
770765

771766
fc = devm_kcalloc(ph->dev, PERF_FC_MAX, sizeof(*fc), GFP_KERNEL);
772767
if (!fc)
773768
return;
774769

775770
ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
776-
PERF_LEVEL_GET, 4, domain,
771+
PERF_LEVEL_GET, 4, dom->id,
777772
&fc[PERF_FC_LEVEL].get_addr, NULL);
778773

779774
ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
780-
PERF_LIMITS_GET, 8, domain,
775+
PERF_LIMITS_GET, 8, dom->id,
781776
&fc[PERF_FC_LIMIT].get_addr, NULL);
782777

783778
if (dom->info.set_perf)
784779
ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
785-
PERF_LEVEL_SET, 4, domain,
780+
PERF_LEVEL_SET, 4, dom->id,
786781
&fc[PERF_FC_LEVEL].set_addr,
787782
&fc[PERF_FC_LEVEL].set_db);
788783

789784
if (dom->set_limits)
790785
ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
791-
PERF_LIMITS_SET, 8, domain,
786+
PERF_LIMITS_SET, 8, dom->id,
792787
&fc[PERF_FC_LIMIT].set_addr,
793788
&fc[PERF_FC_LIMIT].set_db);
794789

795-
*p_fc = fc;
790+
dom->fc_info = fc;
796791
}
797792

798793
static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
@@ -1102,7 +1097,7 @@ static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph)
11021097
scmi_perf_describe_levels_get(ph, dom, version);
11031098

11041099
if (dom->perf_fastchannels)
1105-
scmi_perf_domain_init_fc(ph, dom->id, &dom->fc_info);
1100+
scmi_perf_domain_init_fc(ph, dom);
11061101
}
11071102

11081103
ret = devm_add_action_or_reset(ph->dev, scmi_perf_xa_destroy, pinfo);

0 commit comments

Comments
 (0)