diff options
author | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-09-02 17:40:52 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-09-03 11:20:53 +0200 |
commit | 815ac8567ef9fb56c679da7482bb3266760d69c6 (patch) | |
tree | a0048f0ea06dc7928e1b4004e3e8726f69dce661 /drivers/staging/media/atomisp | |
parent | b2999af93d6202945b92f970951d3fb371247ce9 (diff) |
media: atomisp: atomisp_gmin_platform: check before use
solve this smatch warning:
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c:842 gmin_v1p8_ctrl() warn: variable dereferenced before check 'gs' (see line 832)
By moving the check to happen before its usage.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/staging/media/atomisp')
-rw-r--r-- | drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 1ad0246764a6..135994d44802 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -817,6 +817,9 @@ static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on) int ret; int value; + if (!gs || gs->v1p8_on == on) + return 0; + if (gs->v1p8_gpio >= 0) { pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n", gs->v1p8_gpio); @@ -827,8 +830,6 @@ static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on) pr_err("V1P8 GPIO initialization failed\n"); } - if (!gs || gs->v1p8_on == on) - return 0; gs->v1p8_on = on; if (gs->v1p8_gpio >= 0) |