]> git.baikalelectronics.ru Git - kernel.git/commitdiff
media: tuners: qt1010: replace BUG_ON with a regular error
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 20 Jul 2023 06:20:51 +0000 (08:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 09:11:06 +0000 (11:11 +0200)
[ Upstream commit ee630b29ea44d1851bb6c903f400956604834463 ]

BUG_ON is unnecessary here, and in addition it confuses smatch.
Replacing this with an error return help resolve this smatch
warning:

drivers/media/tuners/qt1010.c:350 qt1010_init() error: buffer overflow 'i2c_data' 34 <= 34

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/tuners/qt1010.c

index 60931367b82ca7abc52dbd9994a5b6e24ea5fcdf..48fc79cd402733aec6d3fdef8a99eb2327cd9eee 100644 (file)
@@ -345,11 +345,12 @@ static int qt1010_init(struct dvb_frontend *fe)
                        else
                                valptr = &tmpval;
 
-                       BUG_ON(i >= ARRAY_SIZE(i2c_data) - 1);
-
-                       err = qt1010_init_meas1(priv, i2c_data[i+1].reg,
-                                               i2c_data[i].reg,
-                                               i2c_data[i].val, valptr);
+                       if (i >= ARRAY_SIZE(i2c_data) - 1)
+                               err = -EIO;
+                       else
+                               err = qt1010_init_meas1(priv, i2c_data[i + 1].reg,
+                                                       i2c_data[i].reg,
+                                                       i2c_data[i].val, valptr);
                        i++;
                        break;
                }