All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] memory: aemif: add support for board files
@ 2018-09-06 11:41 Dan Carpenter
  2018-09-06 12:13 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2018-09-06 11:41 UTC (permalink / raw)
  To: kernel-janitors

Hello Bartosz Golaszewski,

This is a semi-automatic email about new static checker warnings.

The patch 8af70cd2ca50: "memory: aemif: add support for board files" 
from Apr 20, 2018, leads to the following Smatch complaint:

    drivers/memory/ti-aemif.c:415 aemif_probe()
     error: we previously assumed 'pdata' could be null (see line 387)

drivers/memory/ti-aemif.c
   363          if (np && of_device_is_compatible(np, "ti,da850-aemif"))
   364                  aemif->cs_offset = 2;
   365          else if (pdata)
                         ^^^^^
It's possible that when "np" is NULL that means pdata is non-NULL?

   366                  aemif->cs_offset = pdata->cs_offset;
   367  
   368          res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   369          aemif->base = devm_ioremap_resource(dev, res);
   370          if (IS_ERR(aemif->base)) {
   371                  ret = PTR_ERR(aemif->base);
   372                  goto error;
   373          }
   374  
   375          if (np) {
   376                  /*
   377                   * For every controller device node, there is a cs device node
   378                   * that describe the bus configuration parameters. This
   379                   * functions iterate over these nodes and update the cs data
   380                   * array.
   381                   */
   382                  for_each_available_child_of_node(np, child_np) {
   383                          ret = of_aemif_parse_abus_config(pdev, child_np);
   384                          if (ret < 0)
   385                                  goto error;
   386			}
   387		} else if (pdata && pdata->num_abus_data > 0) {
   388			for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
   389				aemif->cs_data[i].cs = pdata->abus_data[i].cs;
   390				aemif_get_hw_params(pdev, i);
   391			}
   392		}
   393	
   394		for (i = 0; i < aemif->num_cs; i++) {
   395			ret = aemif_config_abus(pdev, i);
   396			if (ret < 0) {
   397				dev_err(dev, "Error configuring chip select %d\n",
   398					aemif->cs_data[i].cs);
   399				goto error;
   400			}
   401		}
   402	
   403		/*
   404		 * Create a child devices explicitly from here to guarantee that the
   405		 * child will be probed after the AEMIF timing parameters are set.
   406		 */
   407		if (np) {
   408			for_each_available_child_of_node(np, child_np) {
   409				ret = of_platform_populate(child_np, NULL,
   410							   dev_lookup, dev);
   411				if (ret < 0)
   412					goto error;
   413			}
   414		} else {
   415			for (i = 0; i < pdata->num_sub_devices; i++) {
                                        ^^^^^^^^^^^^^^^^^^^^^^
Not checked.

   416				pdata->sub_devices[i].dev.parent = dev;
   417				ret = platform_device_register(&pdata->sub_devices[i]);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] memory: aemif: add support for board files
  2018-09-06 11:41 [bug report] memory: aemif: add support for board files Dan Carpenter
@ 2018-09-06 12:13 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2018-09-06 12:13 UTC (permalink / raw)
  To: kernel-janitors

2018-09-06 13:41 GMT+02:00 Dan Carpenter <dan.carpenter@oracle.com>:
> Hello Bartosz Golaszewski,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 8af70cd2ca50: "memory: aemif: add support for board files"
> from Apr 20, 2018, leads to the following Smatch complaint:
>
>     drivers/memory/ti-aemif.c:415 aemif_probe()
>      error: we previously assumed 'pdata' could be null (see line 387)
>
> drivers/memory/ti-aemif.c
>    363          if (np && of_device_is_compatible(np, "ti,da850-aemif"))
>    364                  aemif->cs_offset = 2;
>    365          else if (pdata)
>                          ^^^^^
> It's possible that when "np" is NULL that means pdata is non-NULL?
>
>    366                  aemif->cs_offset = pdata->cs_offset;
>    367
>    368          res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>    369          aemif->base = devm_ioremap_resource(dev, res);
>    370          if (IS_ERR(aemif->base)) {
>    371                  ret = PTR_ERR(aemif->base);
>    372                  goto error;
>    373          }
>    374
>    375          if (np) {
>    376                  /*
>    377                   * For every controller device node, there is a cs device node
>    378                   * that describe the bus configuration parameters. This
>    379                   * functions iterate over these nodes and update the cs data
>    380                   * array.
>    381                   */
>    382                  for_each_available_child_of_node(np, child_np) {
>    383                          ret = of_aemif_parse_abus_config(pdev, child_np);
>    384                          if (ret < 0)
>    385                                  goto error;
>    386                  }
>    387          } else if (pdata && pdata->num_abus_data > 0) {
>    388                  for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
>    389                          aemif->cs_data[i].cs = pdata->abus_data[i].cs;
>    390                          aemif_get_hw_params(pdev, i);
>    391                  }
>    392          }
>    393
>    394          for (i = 0; i < aemif->num_cs; i++) {
>    395                  ret = aemif_config_abus(pdev, i);
>    396                  if (ret < 0) {
>    397                          dev_err(dev, "Error configuring chip select %d\n",
>    398                                  aemif->cs_data[i].cs);
>    399                          goto error;
>    400                  }
>    401          }
>    402
>    403          /*
>    404           * Create a child devices explicitly from here to guarantee that the
>    405           * child will be probed after the AEMIF timing parameters are set.
>    406           */
>    407          if (np) {
>    408                  for_each_available_child_of_node(np, child_np) {
>    409                          ret = of_platform_populate(child_np, NULL,
>    410                                                     dev_lookup, dev);
>    411                          if (ret < 0)
>    412                                  goto error;
>    413                  }
>    414          } else {
>    415                  for (i = 0; i < pdata->num_sub_devices; i++) {
>                                         ^^^^^^^^^^^^^^^^^^^^^^
> Not checked.
>
>    416                          pdata->sub_devices[i].dev.parent = dev;
>    417                          ret = platform_device_register(&pdata->sub_devices[i]);
>
> regards,
> dan carpenter

Fix sent to mailing list. Thanks!

Bart

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-06 12:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 11:41 [bug report] memory: aemif: add support for board files Dan Carpenter
2018-09-06 12:13 ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.