tegra: hwpm: fix null check Coverity defect

Null-checking inode suggests that it may be null, but it has already
been dereferenced on path leading to the check. Fix it by adding the
null check in correct sequence.

CID 10127947

Bug 3461002

Change-Id: Ib9135bdb67c489fa52f5dda6725d3cbd1faddd1e
Signed-off-by: Prateek Patel <prpatel@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2645543
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Prateek Patel
2021-12-22 05:06:17 +00:00
committed by mobile promotions
parent 28bcbc77d2
commit 96db4ef5ab

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -530,7 +530,7 @@ end:
static int tegra_soc_hwpm_open(struct inode *inode, struct file *filp) static int tegra_soc_hwpm_open(struct inode *inode, struct file *filp)
{ {
int ret = 0; int ret = 0;
unsigned int minor = iminor(inode); unsigned int minor;
struct tegra_soc_hwpm *hwpm = NULL; struct tegra_soc_hwpm *hwpm = NULL;
u32 i; u32 i;
@@ -542,6 +542,8 @@ static int tegra_soc_hwpm_open(struct inode *inode, struct file *filp)
tegra_soc_hwpm_err("Invalid file"); tegra_soc_hwpm_err("Invalid file");
return -EINVAL; return -EINVAL;
} }
minor = iminor(inode);
if (minor > 0) { if (minor > 0) {
tegra_soc_hwpm_err("Incorrect minor number"); tegra_soc_hwpm_err("Incorrect minor number");
return -EBADFD; return -EBADFD;