From: kbuild test robot <lkp@intel.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: kbuild-all@01.org, Linus Walleij <linus.walleij@linaro.org>,
Russell King <linux@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH 2/2] ARM: integrator: impd1: use struct_size() in devm_kzalloc()
Date: Sat, 5 Jan 2019 13:26:32 +0800 [thread overview]
Message-ID: <201901051339.w6JAsFFZ%fengguang.wu@intel.com> (raw)
In-Reply-To: <9005dbee894cfbada5e57d6ddda9fdf4d711b0a4.1546621488.git.gustavo@embeddedor.com>
[-- Attachment #1: Type: text/plain, Size: 5241 bytes --]
Hi Gustavo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on arm-soc/for-next]
[also build test ERROR on v4.20 next-20190103]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Gustavo-A-R-Silva/Fix-NULL-pointer-dereference-and-use-struct_size/20190105-033105
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git for-next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=arm
All errors (new ones prefixed by >>):
arch/arm/mach-integrator/impd1.c: In function 'impd1_probe':
>> arch/arm/mach-integrator/impd1.c:392:32: error: 'struct lm_device' has no member named 'deva'; did you mean 'dev'?
lookup = devm_kzalloc(&dev->deva,
^~~~
dev
vim +392 arch/arm/mach-integrator/impd1.c
320
321 /*
322 * As this module is bool, it is OK to have this as __ref() - no
323 * probe calls will be done after the initial system bootup, as devices
324 * are discovered as part of the machine startup.
325 */
326 static int __ref impd1_probe(struct lm_device *dev)
327 {
328 struct impd1_module *impd1;
329 int irq_base;
330 int i;
331
332 if (dev->id != module_id)
333 return -EINVAL;
334
335 if (!devm_request_mem_region(&dev->dev, dev->resource.start,
336 SZ_4K, "LM registers"))
337 return -EBUSY;
338
339 impd1 = devm_kzalloc(&dev->dev, sizeof(struct impd1_module),
340 GFP_KERNEL);
341 if (!impd1)
342 return -ENOMEM;
343
344 impd1->base = devm_ioremap(&dev->dev, dev->resource.start, SZ_4K);
345 if (!impd1->base)
346 return -ENOMEM;
347
348 integrator_impd1_clk_init(impd1->base, dev->id);
349
350 if (!devm_request_mem_region(&dev->dev,
351 dev->resource.start + 0x03000000,
352 SZ_4K, "VIC"))
353 return -EBUSY;
354
355 impd1->vic_base = devm_ioremap(&dev->dev,
356 dev->resource.start + 0x03000000,
357 SZ_4K);
358 if (!impd1->vic_base)
359 return -ENOMEM;
360
361 irq_base = vic_init_cascaded(impd1->vic_base, dev->irq,
362 IMPD1_VALID_IRQS, 0);
363
364 lm_set_drvdata(dev, impd1);
365
366 dev_info(&dev->dev, "IM-PD1 found at 0x%08lx\n",
367 (unsigned long)dev->resource.start);
368
369 for (i = 0; i < ARRAY_SIZE(impd1_devs); i++) {
370 struct impd1_device *idev = impd1_devs + i;
371 struct amba_device *d;
372 unsigned long pc_base;
373 char devname[32];
374 int irq1 = idev->irq[0];
375 int irq2 = idev->irq[1];
376
377 /* Translate IRQs to IM-PD1 local numberspace */
378 if (irq1)
379 irq1 += irq_base;
380 if (irq2)
381 irq2 += irq_base;
382
383 pc_base = dev->resource.start + idev->offset;
384 snprintf(devname, 32, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
385
386 /* Add GPIO descriptor lookup table for the PL061 block */
387 if (idev->offset == 0x00400000) {
388 struct gpiod_lookup_table *lookup;
389 char *chipname;
390 char *mmciname;
391
> 392 lookup = devm_kzalloc(&dev->deva,
393 struct_size(lookup, table, 3),
394 GFP_KERNEL);
395 if (!lookup)
396 return -ENOMEM;
397
398 chipname = devm_kstrdup(&dev->dev, devname, GFP_KERNEL);
399 mmciname = kasprintf(GFP_KERNEL, "lm%x:00700", dev->id);
400 lookup->dev_id = mmciname;
401 /*
402 * Offsets on GPIO block 1:
403 * 3 = MMC WP (write protect)
404 * 4 = MMC CD (card detect)
405 *
406 * Offsets on GPIO block 2:
407 * 0 = Up key
408 * 1 = Down key
409 * 2 = Left key
410 * 3 = Right key
411 * 4 = Key lower left
412 * 5 = Key lower right
413 */
414 /* We need the two MMCI GPIO entries */
415 lookup->table[0].chip_label = chipname;
416 lookup->table[0].chip_hwnum = 3;
417 lookup->table[0].con_id = "wp";
418 lookup->table[1].chip_label = chipname;
419 lookup->table[1].chip_hwnum = 4;
420 lookup->table[1].con_id = "cd";
421 lookup->table[1].flags = GPIO_ACTIVE_LOW;
422 gpiod_add_lookup_table(lookup);
423 }
424
425 d = amba_ahb_device_add_res(&dev->dev, devname, pc_base, SZ_4K,
426 irq1, irq2,
427 idev->platform_data, idev->id,
428 &dev->resource);
429 if (IS_ERR(d)) {
430 dev_err(&dev->dev, "unable to register device: %ld\n", PTR_ERR(d));
431 continue;
432 }
433 }
434
435 return 0;
436 }
437
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 67771 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Linus Walleij <linus.walleij@linaro.org>,
linux-kernel@vger.kernel.org,
Russell King <linux@armlinux.org.uk>,
kbuild-all@01.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] ARM: integrator: impd1: use struct_size() in devm_kzalloc()
Date: Sat, 5 Jan 2019 13:26:32 +0800 [thread overview]
Message-ID: <201901051339.w6JAsFFZ%fengguang.wu@intel.com> (raw)
In-Reply-To: <9005dbee894cfbada5e57d6ddda9fdf4d711b0a4.1546621488.git.gustavo@embeddedor.com>
[-- Attachment #1: Type: text/plain, Size: 5241 bytes --]
Hi Gustavo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on arm-soc/for-next]
[also build test ERROR on v4.20 next-20190103]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Gustavo-A-R-Silva/Fix-NULL-pointer-dereference-and-use-struct_size/20190105-033105
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git for-next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=arm
All errors (new ones prefixed by >>):
arch/arm/mach-integrator/impd1.c: In function 'impd1_probe':
>> arch/arm/mach-integrator/impd1.c:392:32: error: 'struct lm_device' has no member named 'deva'; did you mean 'dev'?
lookup = devm_kzalloc(&dev->deva,
^~~~
dev
vim +392 arch/arm/mach-integrator/impd1.c
320
321 /*
322 * As this module is bool, it is OK to have this as __ref() - no
323 * probe calls will be done after the initial system bootup, as devices
324 * are discovered as part of the machine startup.
325 */
326 static int __ref impd1_probe(struct lm_device *dev)
327 {
328 struct impd1_module *impd1;
329 int irq_base;
330 int i;
331
332 if (dev->id != module_id)
333 return -EINVAL;
334
335 if (!devm_request_mem_region(&dev->dev, dev->resource.start,
336 SZ_4K, "LM registers"))
337 return -EBUSY;
338
339 impd1 = devm_kzalloc(&dev->dev, sizeof(struct impd1_module),
340 GFP_KERNEL);
341 if (!impd1)
342 return -ENOMEM;
343
344 impd1->base = devm_ioremap(&dev->dev, dev->resource.start, SZ_4K);
345 if (!impd1->base)
346 return -ENOMEM;
347
348 integrator_impd1_clk_init(impd1->base, dev->id);
349
350 if (!devm_request_mem_region(&dev->dev,
351 dev->resource.start + 0x03000000,
352 SZ_4K, "VIC"))
353 return -EBUSY;
354
355 impd1->vic_base = devm_ioremap(&dev->dev,
356 dev->resource.start + 0x03000000,
357 SZ_4K);
358 if (!impd1->vic_base)
359 return -ENOMEM;
360
361 irq_base = vic_init_cascaded(impd1->vic_base, dev->irq,
362 IMPD1_VALID_IRQS, 0);
363
364 lm_set_drvdata(dev, impd1);
365
366 dev_info(&dev->dev, "IM-PD1 found at 0x%08lx\n",
367 (unsigned long)dev->resource.start);
368
369 for (i = 0; i < ARRAY_SIZE(impd1_devs); i++) {
370 struct impd1_device *idev = impd1_devs + i;
371 struct amba_device *d;
372 unsigned long pc_base;
373 char devname[32];
374 int irq1 = idev->irq[0];
375 int irq2 = idev->irq[1];
376
377 /* Translate IRQs to IM-PD1 local numberspace */
378 if (irq1)
379 irq1 += irq_base;
380 if (irq2)
381 irq2 += irq_base;
382
383 pc_base = dev->resource.start + idev->offset;
384 snprintf(devname, 32, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
385
386 /* Add GPIO descriptor lookup table for the PL061 block */
387 if (idev->offset == 0x00400000) {
388 struct gpiod_lookup_table *lookup;
389 char *chipname;
390 char *mmciname;
391
> 392 lookup = devm_kzalloc(&dev->deva,
393 struct_size(lookup, table, 3),
394 GFP_KERNEL);
395 if (!lookup)
396 return -ENOMEM;
397
398 chipname = devm_kstrdup(&dev->dev, devname, GFP_KERNEL);
399 mmciname = kasprintf(GFP_KERNEL, "lm%x:00700", dev->id);
400 lookup->dev_id = mmciname;
401 /*
402 * Offsets on GPIO block 1:
403 * 3 = MMC WP (write protect)
404 * 4 = MMC CD (card detect)
405 *
406 * Offsets on GPIO block 2:
407 * 0 = Up key
408 * 1 = Down key
409 * 2 = Left key
410 * 3 = Right key
411 * 4 = Key lower left
412 * 5 = Key lower right
413 */
414 /* We need the two MMCI GPIO entries */
415 lookup->table[0].chip_label = chipname;
416 lookup->table[0].chip_hwnum = 3;
417 lookup->table[0].con_id = "wp";
418 lookup->table[1].chip_label = chipname;
419 lookup->table[1].chip_hwnum = 4;
420 lookup->table[1].con_id = "cd";
421 lookup->table[1].flags = GPIO_ACTIVE_LOW;
422 gpiod_add_lookup_table(lookup);
423 }
424
425 d = amba_ahb_device_add_res(&dev->dev, devname, pc_base, SZ_4K,
426 irq1, irq2,
427 idev->platform_data, idev->id,
428 &dev->resource);
429 if (IS_ERR(d)) {
430 dev_err(&dev->dev, "unable to register device: %ld\n", PTR_ERR(d));
431 continue;
432 }
433 }
434
435 return 0;
436 }
437
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 67771 bytes --]
[-- Attachment #3: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-01-05 6:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-04 17:13 [PATCH 0/2] Fix NULL pointer dereference and use struct_size Gustavo A. R. Silva
2019-01-04 17:13 ` Gustavo A. R. Silva
2019-01-04 17:17 ` [PATCH 1/2] ARM: integrator: impd1: fix NULL pointer dereference Gustavo A. R. Silva
2019-01-04 17:17 ` Gustavo A. R. Silva
2019-01-11 12:22 ` Linus Walleij
2019-01-11 12:22 ` Linus Walleij
2019-01-04 17:18 ` [PATCH 2/2] ARM: integrator: impd1: use struct_size() in devm_kzalloc() Gustavo A. R. Silva
2019-01-04 17:18 ` Gustavo A. R. Silva
2019-01-05 5:26 ` kbuild test robot [this message]
2019-01-05 5:26 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201901051339.w6JAsFFZ%fengguang.wu@intel.com \
--to=lkp@intel.com \
--cc=gustavo@embeddedor.com \
--cc=kbuild-all@01.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.