From 0fb82ec0268b5e46b0fefc677c9fa62707c61c67 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 2 Jul 2013 20:32:39 -0700 Subject: Input: cyttsp4 - silence shift wrap warning "*max" is a size_t (long) type but "1" is an int so static checkers complain that the shift could wrap. Signed-off-by: Dan Carpenter Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/cyttsp4_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input/touchscreen/cyttsp4_core.c') diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 963da052c15e..7aa4a349a07e 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -153,7 +153,7 @@ static int cyttsp4_hw_reset(struct cyttsp4 *cd) */ static int cyttsp4_bits_2_bytes(unsigned int nbits, size_t *max) { - *max = 1 << nbits; + *max = 1UL << nbits; return (nbits + 7) / 8; } -- cgit From 7c4c018aadadf1db2c27d6b9f0280700a2619861 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 2 Jul 2013 20:32:53 -0700 Subject: Input: cyttsp4 - silence NULL dereference warning If "cd" were NULL then we would dereference it when we print the error message. Fortunately enough, it can't ever be NULL so we can remove those lines. Signed-off-by: Dan Carpenter Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/cyttsp4_core.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/input/touchscreen/cyttsp4_core.c') diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 7aa4a349a07e..851e3ff80437 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -1450,11 +1450,6 @@ static void cyttsp4_watchdog_work(struct work_struct *work) u8 *mode; int retval; - if (cd == NULL) { - dev_err(cd->dev, "%s: NULL context pointer\n", __func__); - return; - } - mutex_lock(&cd->system_lock); retval = cyttsp4_load_status_regs(cd); if (retval < 0) { -- cgit From 394fc05b7967a043e26b4343011a319390801c8b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 2 Jul 2013 20:32:58 -0700 Subject: Input: cyttsp4 - leak on error path in probe() We leak "cd" if the cd->xfer_buf allocation fails. It was weird to "goto error_gpio_irq" so I changed the label name. (Label names should reflect the label location not the goto location otherwise you get an "all roads lead to Rome problem"). Signed-off-by: Dan Carpenter Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/cyttsp4_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/input/touchscreen/cyttsp4_core.c') diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 851e3ff80437..a7987e170071 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -2025,7 +2025,7 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, if (!cd->xfer_buf) { dev_err(dev, "%s: Error, kzalloc\n", __func__); rc = -ENOMEM; - goto error_alloc_data; + goto error_free_cd; } /* Initialize device info */ @@ -2049,7 +2049,7 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, cd->irq = gpio_to_irq(cd->cpdata->irq_gpio); if (cd->irq < 0) { rc = -EINVAL; - goto error_gpio_irq; + goto error_free_cd; } dev_set_drvdata(dev, cd); @@ -2117,7 +2117,7 @@ error_request_irq: if (cd->cpdata->init) cd->cpdata->init(cd->cpdata, 0, dev); dev_set_drvdata(dev, NULL); -error_gpio_irq: +error_free_cd: kfree(cd); error_alloc_data: error_no_pdata: -- cgit From 57961e3ba72f4a8a1aa52e978020ecc2ca03a79f Mon Sep 17 00:00:00 2001 From: Ferruh Yigit Date: Thu, 4 Jul 2013 14:02:45 -0700 Subject: Input: cyttsp4 - kfree xfer_buf on error path in probe() If probe() fails after cd->xfer_buf allocated, it will not freed. Added kfree(cd->xfer_buf) with and error label. Signed-off-by: Ferruh Yigit Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/cyttsp4_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/input/touchscreen/cyttsp4_core.c') diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index a7987e170071..edcf7993034b 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -2049,7 +2049,7 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, cd->irq = gpio_to_irq(cd->cpdata->irq_gpio); if (cd->irq < 0) { rc = -EINVAL; - goto error_free_cd; + goto error_free_xfer; } dev_set_drvdata(dev, cd); @@ -2117,6 +2117,8 @@ error_request_irq: if (cd->cpdata->init) cd->cpdata->init(cd->cpdata, 0, dev); dev_set_drvdata(dev, NULL); +error_free_xfer: + kfree(cd->xfer_buf); error_free_cd: kfree(cd); error_alloc_data: -- cgit