OSDN Git Service

fsi/core: Fix error paths on CFAM init
authorJeremy Kerr <jk@ozlabs.org>
Fri, 28 Jun 2019 08:07:37 +0000 (16:07 +0800)
committerJoel Stanley <joel@jms.id.au>
Wed, 3 Jul 2019 01:12:53 +0000 (10:42 +0930)
commit371975b0b07520c85098652d561639837a60a905
treeaac84f2d733510e69e1d8031ea4a8cf7a818b51a
parentafd26118f0dcf29db031a213f6f95c46ff3bdcbe
fsi/core: Fix error paths on CFAM init

Change d1dcd67825 re-worked the struct fsi_slave initialisation in
fsi_slave_init, but introduced a few inconsitencies: the slave->dev is
now registered through cdev_device_add, but we may kfree() the device
out from underneath the cdev registration. We may also leave an IDA
allocated.

This change fixes the error paths, so that we kfree() only before the
device is registered with the core code. We also move the smode write to
before we start creating proper devices, as it's the most likely to
fail. We also remove the IDA-allocated minor on error, and properly
clean up the of_node.

Fixes: d1dcd6782576 ("fsi: Add cfam char devices")
Reported-by: Lei YU <mine260309@gmail.com>
Tested-by: John Wang <wangzqbj@inspur.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
drivers/fsi/fsi-core.c