HSI: core: fix resource leaks in hsi_add_client_from_dt()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 9 Apr 2021 11:08:17 +0000 (14:08 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:40:26 +0000 (10:40 +0200)
commit08557db2c9fd5660ac788b6945affdf761ce2463
treed0a052439c97ab484e2183bb9a60760fe98df3b0
parenta8deef45429daaf34fd2dd7221abf7c4463ef8e4
HSI: core: fix resource leaks in hsi_add_client_from_dt()

[ Upstream commit 5c08b0f75575648032f309a6f58294453423ed93 ]

If some of the allocations fail between the dev_set_name() and the
device_register() then the name will not be freed.  Fix this by
moving dev_set_name() directly in front of the call to device_register().

Fixes: a2aa24734d9d ("HSI: Add common DT binding for HSI client devices")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hsi/hsi_core.c