Skip to content

Commit

Permalink
powerpc/powernv: add NULL check after kzalloc
Browse files Browse the repository at this point in the history
[ Upstream commit ceffa63 ]

Fixes coccicheck warning:

./arch/powerpc/platforms/powernv/opal.c:813:1-5:
	alloc with no test, possible model on line 814

Add NULL check after kzalloc.

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200509020838.121660-1-chenzhou10@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Chen Zhou authored and gregkh committed Jun 24, 2020
1 parent 24f5239 commit 38b6829
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/powerpc/platforms/powernv/opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,10 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
goto out;

attr = kzalloc(sizeof(*attr), GFP_KERNEL);
if (!attr) {
rc = -ENOMEM;
goto out;
}
name = kstrdup(export_name, GFP_KERNEL);
if (!name) {
rc = -ENOMEM;
Expand Down

0 comments on commit 38b6829

Please sign in to comment.