Message ID | 1461251430-67026-2-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Hi, [auto build test WARNING on next-20160421] [also build test WARNING on v4.6-rc4] [cannot apply to robh/for-next asoc/for-next v4.6-rc4 v4.6-rc3 v4.6-rc2] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/Fixes-cleanups-in-dw_dmac-affects-on-few-subsystems/20160421-231541 config: i386-randconfig-x003-201616 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386 Note: it may well be a FALSE warning. FWIW you are at least aware of it now. http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings All warnings (new ones prefixed by >>): drivers/dma/dw/platform.c: In function 'dw_probe': >> drivers/dma/dw/platform.c:119:20: warning: 'pdata' may be used uninitialized in this function [-Wmaybe-uninitialized] pdata->nr_masters = nr_masters; ^ drivers/dma/dw/platform.c:104:31: note: 'pdata' was declared here struct dw_dma_platform_data *pdata; ^ vim +/pdata +119 drivers/dma/dw/platform.c 103 struct device_node *np = pdev->dev.of_node; 104 struct dw_dma_platform_data *pdata; 105 u32 tmp, arr[DW_DMA_MAX_NR_MASTERS]; 106 u32 nr_masters; 107 u32 nr_channels; 108 109 if (!np) { 110 dev_err(&pdev->dev, "Missing DT data\n"); 111 return NULL; 112 } 113 114 if (of_property_read_u32(np, "dma-masters", &nr_masters)) 115 return NULL; 116 if (nr_masters < 1 || nr_masters > DW_DMA_MAX_NR_MASTERS) 117 return NULL; 118 > 119 pdata->nr_masters = nr_masters; 120 121 if (of_property_read_u32(np, "dma-channels", &nr_channels)) 122 return NULL; 123 124 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 125 if (!pdata) 126 return NULL; 127 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c index 23616c5..922b102 100644 --- a/drivers/dma/dw/platform.c +++ b/drivers/dma/dw/platform.c @@ -103,6 +103,7 @@ dw_dma_parse_dt(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct dw_dma_platform_data *pdata; u32 tmp, arr[DW_DMA_MAX_NR_MASTERS]; + u32 nr_masters; u32 nr_channels; if (!np) { @@ -110,6 +111,13 @@ dw_dma_parse_dt(struct platform_device *pdev) return NULL; } + if (of_property_read_u32(np, "dma-masters", &nr_masters)) + return NULL; + if (nr_masters < 1 || nr_masters > DW_DMA_MAX_NR_MASTERS) + return NULL; + + pdata->nr_masters = nr_masters; + if (of_property_read_u32(np, "dma-channels", &nr_channels)) return NULL; @@ -131,17 +139,10 @@ dw_dma_parse_dt(struct platform_device *pdev) if (!of_property_read_u32(np, "block_size", &tmp)) pdata->block_size = tmp; - if (!of_property_read_u32(np, "dma-masters", &tmp)) { - if (tmp > DW_DMA_MAX_NR_MASTERS) - return NULL; - - pdata->nr_masters = tmp; - } - - if (!of_property_read_u32_array(np, "data_width", arr, - pdata->nr_masters)) - for (tmp = 0; tmp < pdata->nr_masters; tmp++) + if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) { + for (tmp = 0; tmp < nr_masters; tmp++) pdata->data_width[tmp] = arr[tmp]; + } return pdata; }
The nr_masters value equal to 0 is invalid since this DMA controller has to have at least one master. Check this before we proceed with the rest of properties. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/dma/dw/platform.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)