@@ -28,7 +28,6 @@ struct fsl_soc_die_attr {
2828static struct guts * guts ;
2929static struct soc_device_attribute soc_dev_attr ;
3030static struct soc_device * soc_dev ;
31- static struct device_node * root ;
3231
3332
3433/* SoC die attribute definition for QorIQ platform */
@@ -138,7 +137,7 @@ static u32 fsl_guts_get_svr(void)
138137
139138static int fsl_guts_probe (struct platform_device * pdev )
140139{
141- struct device_node * np = pdev -> dev .of_node ;
140+ struct device_node * root , * np = pdev -> dev .of_node ;
142141 struct device * dev = & pdev -> dev ;
143142 const struct fsl_soc_die_attr * soc_die ;
144143 const char * machine ;
@@ -159,8 +158,14 @@ static int fsl_guts_probe(struct platform_device *pdev)
159158 root = of_find_node_by_path ("/" );
160159 if (of_property_read_string (root , "model" , & machine ))
161160 of_property_read_string_index (root , "compatible" , 0 , & machine );
162- if (machine )
163- soc_dev_attr .machine = machine ;
161+ if (machine ) {
162+ soc_dev_attr .machine = devm_kstrdup (dev , machine , GFP_KERNEL );
163+ if (!soc_dev_attr .machine ) {
164+ of_node_put (root );
165+ return - ENOMEM ;
166+ }
167+ }
168+ of_node_put (root );
164169
165170 svr = fsl_guts_get_svr ();
166171 soc_die = fsl_soc_die_match (svr , fsl_soc_die );
@@ -195,7 +200,6 @@ static int fsl_guts_probe(struct platform_device *pdev)
195200static int fsl_guts_remove (struct platform_device * dev )
196201{
197202 soc_device_unregister (soc_dev );
198- of_node_put (root );
199203 return 0 ;
200204}
201205
0 commit comments