Skip to contentSkip to conversation

EDAC/sifive: Add EDAC platform driver for SiFive SoCs

bug report Dan Carpenter 2 participants 2 messages Aug 14, 2019 – Aug 20, 2019 EDAC-core

lore
Share & tools
lore
#0 lore raw

Hello Yash Shah,

The patch 91abaeaaff35: "EDAC/sifive: Add EDAC platform driver for SiFive SoCs" from May 6, 2019, leads to the following static checker warning:

	drivers/edac/sifive_edac.c:60 ecc_register()
	warn: 'p->dci' can also be NULL

drivers/edac/sifive_edac.c

    43  static int ecc_register(struct platform_device *pdev)
    44  {
    45          struct sifive_edac_priv *p;
    46  
    47          p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
    48          if (!p)
    49                  return -ENOMEM;
    50  
    51          p->notifier.notifier_call = ecc_err_event;
    52          platform_set_drvdata(pdev, p);
    53  
    54          p->dci = edac_device_alloc_ctl_info(0, "sifive_ecc", 1, "sifive_ecc",
    55                                              1, 1, NULL, 0,
    56                                              edac_device_alloc_index());
    57          if (IS_ERR(p->dci))
                    ^^^^^^^^^^^^^^

The edac_device_alloc_ctl_info() function never returns error pointers, it returns NULL.

    58                  return PTR_ERR(p->dci);
    59  
    60          p->dci->dev = &pdev->dev;
    61          p->dci->mod_name = "Sifive ECC Manager";
    62          p->dci->ctl_name = dev_name(&pdev->dev);
    63          p->dci->dev_name = dev_name(&pdev->dev);
    64  

regards,
dan carpenter

#1 lore raw
Quoted 27 lines · Dan Carpenter

Hello Yash Shah,

The patch 91abaeaaff35: "EDAC/sifive: Add EDAC platform driver for SiFive SoCs" from May 6, 2019, leads to the following static checker warning:

        drivers/edac/sifive_edac.c:60 ecc_register()
        warn: 'p->dci' can also be NULL

drivers/edac/sifive_edac.c

    43  static int ecc_register(struct platform_device *pdev)
    44  {
    45          struct sifive_edac_priv *p;
    46
    47          p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
    48          if (!p)
    49                  return -ENOMEM;
    50
    51          p->notifier.notifier_call = ecc_err_event;
    52          platform_set_drvdata(pdev, p);
    53
    54          p->dci = edac_device_alloc_ctl_info(0, "sifive_ecc", 1, "sifive_ecc",
    55                                              1, 1, NULL, 0,
    56                                              edac_device_alloc_index());
    57          if (IS_ERR(p->dci))
                    ^^^^^^^^^^^^^^
Quoted 3 lines

The edac_device_alloc_ctl_info() function never returns error pointers, it returns NULL.

Thanks for reporting this bug. Currently, a discussion is going on to move this code into some other directory. The patch for the same has been submitted [0].
I will take care of this bug once that patch is accepted.

- Yash

[0] https://lkml.org/lkml/2019/8/18/39