@@ -29,20 +29,70 @@ DECLARE_SOF_UUID("component", comp_uuid, 0x7c42ce8b, 0x0108, 0x43d0,
2929
3030DECLARE_TR_CTX (comp_tr , SOF_UUID (comp_uuid ), LOG_LEVEL_INFO );
3131
32- static const struct comp_driver * get_drv (uint32_t type )
32+ static const struct comp_driver * get_drv (struct sof_ipc_comp * comp )
3333{
3434 struct comp_driver_list * drivers = comp_drivers_get ();
3535 struct list_item * clist ;
3636 const struct comp_driver * drv = NULL ;
3737 struct comp_driver_info * info ;
38+ struct sof_ipc_comp_ext * comp_ext ;
3839 uint32_t flags ;
3940
4041 irq_local_disable (flags );
4142
43+ /* do we have extended data ? */
44+ if (!comp -> ext_data_length )
45+ goto comp_type_match ;
46+
47+ /* Basic sanity check of the total size and extended data
48+ * length. A bit lax because in this generic code we don't know
49+ * which derived comp we have and how much its specific members
50+ * add.
51+ */
52+ if (comp -> hdr .size < sizeof (* comp ) + comp -> ext_data_length ) {
53+ tr_err (& comp_tr , "Invalid size, hdr.size=0x%x, ext_data_length=0x%x\n" ,
54+ comp -> hdr .size , comp -> ext_data_length );
55+ goto out ;
56+ }
57+
58+ comp_ext = (struct sof_ipc_comp_ext * )
59+ ((uint8_t * )comp + comp -> hdr .size -
60+ comp -> ext_data_length );
61+
62+ /* UUID is first item in extended data - check its big enough */
63+ if (comp -> ext_data_length < UUID_SIZE ) {
64+ tr_err (& comp_tr , "UUID is invalid!\n" );
65+ goto out ;
66+ }
67+
68+ /* search driver list with UUID */
69+ list_for_item (clist , & drivers -> list ) {
70+ info = container_of (clist , struct comp_driver_info ,
71+ list );
72+ if (!memcmp (info -> drv -> uid , comp_ext -> uuid ,
73+ UUID_SIZE )) {
74+ tr_dbg (& comp_tr ,
75+ "get_drv_from_uuid(), found driver type %d, uuid %s" ,
76+ info -> drv -> type ,
77+ info -> drv -> tctx -> uuid_p );
78+ drv = info -> drv ;
79+ goto out ;
80+ }
81+ }
82+
83+ tr_err (& comp_tr , "get_drv(): the provided UUID (%8x%8x%8x%8x) doesn't match to any driver!" ,
84+ * (uint32_t * )(& comp_ext -> uuid [0 ]),
85+ * (uint32_t * )(& comp_ext -> uuid [4 ]),
86+ * (uint32_t * )(& comp_ext -> uuid [8 ]),
87+ * (uint32_t * )(& comp_ext -> uuid [12 ]));
88+
89+ goto out ;
90+
91+ comp_type_match :
4292 /* search driver list for driver type */
4393 list_for_item (clist , & drivers -> list ) {
4494 info = container_of (clist , struct comp_driver_info , list );
45- if (info -> drv -> type == type ) {
95+ if (info -> drv -> type == comp -> type ) {
4696 drv = info -> drv ;
4797 platform_shared_commit (info , sizeof (* info ));
4898 goto out ;
@@ -63,7 +113,7 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp)
63113 const struct comp_driver * drv ;
64114
65115 /* find the driver for our new component */
66- drv = get_drv (comp -> type );
116+ drv = get_drv (comp );
67117 if (!drv ) {
68118 tr_err (& comp_tr , "comp_new(): driver not found, comp->type = %u" ,
69119 comp -> type );
0 commit comments