linux/arch
Tony Lindgren b1dd11d60e ARM: OMAP2+: Remove bogus IS_ERR_OR_NULL checking from id.c
Commit 6770b211 (ARM: OMAP2+: Export SoC information to userspace)
had some broken return value handling as noted by Russell King:

+       soc_dev = soc_device_register(soc_dev_attr);
+       if (IS_ERR_OR_NULL(soc_dev)) {
+               kfree(soc_dev_attr);
+               return;
+       }
+
+       parent = soc_device_to_device(soc_dev);
+       if (!IS_ERR_OR_NULL(parent))
+               device_create_file(parent, &omap_soc_attr);

This is nonsense.  For the first, IS_ERR() is sufficient.  For the second,
tell me what error checking is required in the return value of this
function:

struct device *soc_device_to_device(struct soc_device *soc_dev)
{
        return &soc_dev->dev;
}

when you've already determined that the passed soc_dev is a valid pointer.
If you read the comments against the prototype:

/**
 * soc_device_to_device - helper function to fetch struct device
 * @soc: Previously registered SoC device container
 */
struct device *soc_device_to_device(struct soc_device *soc);

if "soc" is valid, it means the "previously registered SoC device container"
must have succeeded and that can only happen if the struct device has been
registered.  Ergo, there will always be a valid struct device pointer for
any registered SoC device container.  Therefore, if soc_device_register()
succeeds, then the return value from soc_device_to_device() will always be
valid and no error checking of it is required.

Simples.  The rule as ever applies here: get to know the APIs your using
and don't fumble around in the dark hoping that you'll get this stuff
right.

Fix it as noted by Russell.

Reported-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2013-05-09 09:06:27 -07:00
..
alpha Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-01 17:51:54 -07:00
arc arc, print-fatal-signals: reduce duplicated information 2013-04-30 17:04:02 -07:00
arm ARM: OMAP2+: Remove bogus IS_ERR_OR_NULL checking from id.c 2013-05-09 09:06:27 -07:00
arm64 ARM: arm-soc: late cleanups 2013-05-07 11:22:14 -07:00
avr32 MMC highlights for 3.10: 2013-05-04 13:45:17 -07:00
blackfin We get rid of the general module prefix confusion with a binary config option, 2013-05-05 10:58:06 -07:00
c6x dump_stack: unify debug information printed by show_regs() 2013-04-30 17:04:02 -07:00
cris proc: Use PDE attribute setting accessor functions 2013-05-07 15:01:11 -04:00
frv Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
h8300 We get rid of the general module prefix confusion with a binary config option, 2013-05-05 10:58:06 -07:00
hexagon Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rkuo/linux-hexagon-kernel 2013-05-01 07:43:05 -07:00
ia64 Merge tag 'kvm-3.10-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm 2013-05-05 14:47:31 -07:00
m32r Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
m68k Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2013-05-01 07:21:43 -07:00
metag We get rid of the general module prefix confusion with a binary config option, 2013-05-05 10:58:06 -07:00
microblaze Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2013-05-01 07:21:43 -07:00
mips mips: single_open() leaks 2013-05-05 00:10:21 -04:00
mn10300 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
openrisc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rkuo/linux-hexagon-kernel 2013-05-01 07:43:05 -07:00
parisc parisc: remove the second argument of kmap_atomic() 2013-05-07 18:38:27 -07:00
powerpc powerpc: Make hard_irq_disable() do the right thing vs. irq tracing 2013-05-07 17:13:57 +10:00
s390 aio: don't include aio.h in sched.h 2013-05-07 20:16:25 -07:00
score Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-01 17:51:54 -07:00
sh ARM: arm-soc platform updates for 3.10, part 2 2013-05-07 10:57:51 -07:00
sparc mm/SPARC: use common help functions to free reserved pages 2013-05-07 18:38:26 -07:00
tile Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-01 17:51:54 -07:00
um Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-07 15:14:53 -07:00
unicore32 Merge branch 'akpm' (incoming from Andrew) 2013-04-30 17:37:43 -07:00
x86 Merge branch 'rwsem-optimizations' 2013-05-07 09:22:03 -07:00
xtensa block_device_operations->release() should return void 2013-05-07 02:16:21 -04:00
.gitignore
Kconfig We get rid of the general module prefix confusion with a binary config option, 2013-05-05 10:58:06 -07:00