From: <dan.carpenter@oracle.com>
To: <mchehab+huawei@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: [bug report] media: atomisp: place all gpio parsing together
Date: Tue, 21 Jul 2020 13:49:46 +0300 [thread overview]
Message-ID: <20200721104946.GA149039@mwanda> (raw)
Hello Mauro Carvalho Chehab,
This is a semi-automatic email about new static checker warnings.
The patch 79317baaaea2: "media: atomisp: place all gpio parsing
together" from Jun 21, 2020, leads to the following Smatch complaint:
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c:830 gmin_v1p8_ctrl()
warn: variable dereferenced before check 'gs' (see line 820)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
814 static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on)
815 {
816 struct gmin_subdev *gs = find_gmin_subdev(subdev);
817 int ret;
818 int value;
819
820 if (gs->v1p8_gpio >= 0) {
^^
New dereference.
821 pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n",
822 gs->v1p8_gpio);
823 ret = gpio_request(gs->v1p8_gpio, "camera_v1p8_en");
824 if (!ret)
825 ret = gpio_direction_output(gs->v1p8_gpio, 0);
826 if (ret)
827 pr_err("V1P8 GPIO initialization failed\n");
828 }
829
830 if (!gs || gs->v1p8_on == on)
^^
Too late.
831 return 0;
832 gs->v1p8_on = on;
833
834 if (gs->v1p8_gpio >= 0)
835 gpio_set_value(gs->v1p8_gpio, on);
Could we combine this with the first "if (gs->v1p8_gpio >= 0) {"
condition? This code is looking pretty subtle so maybe not.
836
837 if (gs->v1p8_reg) {
838 regulator_set_voltage(gs->v1p8_reg, 1800000, 1800000);
839 if (on)
840 return regulator_enable(gs->v1p8_reg);
841 else
842 return regulator_disable(gs->v1p8_reg);
843 }
844
regards,
dan carpenter
reply other threads:[~2020-07-21 10:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200721104946.GA149039@mwanda \
--to=dan.carpenter@oracle.com \
--cc=mchehab+huawei@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.