irblaster: meson: fix Coverity errors [1/2]
authorBichao Zheng <bichao.zheng@amlogic.com>
Thu, 12 Sep 2019 07:17:46 +0000 (15:17 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Fri, 27 Sep 2019 11:58:28 +0000 (04:58 -0700)
PD#SWPL-13973

Problem:
irblaster Coverity errors.

Solution:
1. Properly release resources.
2. Fix return value type.

Verify:
test pass on g12a_u200_v1

Change-Id: I50054ba3ac9f02aeeaa005b7823416b1c4c9a196
Signed-off-by: Bichao Zheng <bichao.zheng@amlogic.com>
drivers/amlogic/irblaster/irblaster-nec-encoder.c
drivers/amlogic/irblaster/irblaster-rca-encoder.c
drivers/amlogic/irblaster/sysfs.c

index 107383f..67aaacf 100644 (file)
@@ -97,7 +97,8 @@ int irblaster_nec_encode(enum irblaster_protocol protocol,
                         unsigned int commmand,
                         unsigned int *data)
 {
-       u32 raw, ret;
+       int ret;
+       u32 raw;
 
        if (protocol >= IRBLASTER_PROTOCOL_MAX)
                return -ENODEV;
index 21068b6..e825faf 100644 (file)
@@ -61,7 +61,8 @@ static u32 irblaster_rca_scancode_to_raw(enum irblaster_protocol protocol,
 int irblaster_rca_encode(enum irblaster_protocol protocol, unsigned int addr,
                         unsigned int commmand, unsigned int *data)
 {
-       u32 raw, ret;
+       int ret;
+       u32 raw;
 
        /* Convert a RCA scancode to raw rca data */
        raw = irblaster_rca_scancode_to_raw(protocol, addr, commmand);
index 650be64..359d439 100644 (file)
@@ -47,6 +47,7 @@ static ssize_t send_store(struct device *dev,
                        if (ret) {
                                pr_err("Invalid tone\n");
                                mutex_unlock(&chip->sys_lock);
+                               kfree(buffer);
                                return ret;
                        }
                        buffer[m] = val * 10;