* re: Input: add Cypress TTSP capacitive multi-touch screen support
@ 2012-02-01 9:40 Dan Carpenter
2012-02-10 0:04 ` Javier Martinez Canillas
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-02-01 9:40 UTC (permalink / raw)
To: javier; +Cc: linux-input
Hello Javier Martinez Canillas,
This is a semi-automatic email about new static checker warnings.
The patch 4065d1e7b216: "Input: add Cypress TTSP capacitive
multi-touch screen support" from Jan 31, 2012, leads to the following
Smatch complaint:
drivers/input/touchscreen/cyttsp_core.c +526 cyttsp_probe()
warn: variable dereferenced before check 'dev' (see line 521)
drivers/input/touchscreen/cyttsp_core.c
520 {
521 const struct cyttsp_platform_data *pdata = dev->platform_data;
^^^^^
dereference.
522 struct cyttsp *ts;
523 struct input_dev *input_dev;
524 int error;
525
526 if (!dev || !bus_ops || !pdata || !pdata->name || irq <= 0) {
^^^^
check.
527 error = -EINVAL;
528 goto err_out;
"dev" is never NULL here so the check can be removed probably.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Input: add Cypress TTSP capacitive multi-touch screen support
2012-02-01 9:40 Input: add Cypress TTSP capacitive multi-touch screen support Dan Carpenter
@ 2012-02-10 0:04 ` Javier Martinez Canillas
0 siblings, 0 replies; 2+ messages in thread
From: Javier Martinez Canillas @ 2012-02-10 0:04 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-input
On Wed, Feb 1, 2012 at 10:40 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Hello Javier Martinez Canillas,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 4065d1e7b216: "Input: add Cypress TTSP capacitive
> multi-touch screen support" from Jan 31, 2012, leads to the following
> Smatch complaint:
>
> drivers/input/touchscreen/cyttsp_core.c +526 cyttsp_probe()
> warn: variable dereferenced before check 'dev' (see line 521)
>
> drivers/input/touchscreen/cyttsp_core.c
> 520 {
> 521 const struct cyttsp_platform_data *pdata = dev->platform_data;
> ^^^^^
> dereference.
>
> 522 struct cyttsp *ts;
> 523 struct input_dev *input_dev;
> 524 int error;
> 525
> 526 if (!dev || !bus_ops || !pdata || !pdata->name || irq <= 0) {
> ^^^^
> check.
>
> 527 error = -EINVAL;
> 528 goto err_out;
>
> "dev" is never NULL here so the check can be removed probably.
>
> regards,
> dan carpenter
Hello Dan,
Thank you for running smatch on this driver.
dev is never NULL since both i2c and spi bus drivers pass as an
argument a pointer to a member of an previously allocated structure
(struct i2c_client and struct spi_device respectively).
But you are right that is wrong to check after dereferencing the
pointer. Instead of remove the !dev check I will move the pdata
assignment after the check. I'll send a patch now to fix the issue.
Thank you and best regards,
Javier
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-10 0:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01 9:40 Input: add Cypress TTSP capacitive multi-touch screen support Dan Carpenter
2012-02-10 0:04 ` Javier Martinez Canillas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).