Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2018-07-09 18:43:31 +0800
committerColy Li <colyli@suse.de>2018-07-09 18:47:09 +0800
commit4c47ad88fc338ae238c9000807159feb53a210a1 (patch)
treef9deb36aa4f24dfc5f2a4446f0a027ecfe82a99e
parent96e18b111ff169939ed7465a450db2caee8197ab (diff)
media: smiapp: fix timeout checking in smiapp_read_nvm
(bsc#1099918).
-rw-r--r--patches.suse/0001-media-smiapp-fix-timeout-checking-in-smiapp_read_nvm.patch62
-rw-r--r--series.conf1
2 files changed, 63 insertions, 0 deletions
diff --git a/patches.suse/0001-media-smiapp-fix-timeout-checking-in-smiapp_read_nvm.patch b/patches.suse/0001-media-smiapp-fix-timeout-checking-in-smiapp_read_nvm.patch
new file mode 100644
index 0000000000..b1917746a8
--- /dev/null
+++ b/patches.suse/0001-media-smiapp-fix-timeout-checking-in-smiapp_read_nvm.patch
@@ -0,0 +1,62 @@
+From 7a2148dfda8001c983f0effd9afd8a7fa58e99c4 Mon Sep 17 00:00:00 2001
+From: Colin Ian King <colin.king@canonical.com>
+Date: Wed, 25 Apr 2018 11:04:21 -0400
+Subject: [PATCH] media: smiapp: fix timeout checking in smiapp_read_nvm
+Git-commit: 7a2148dfda8001c983f0effd9afd8a7fa58e99c4
+Patch-mainline: v4.18-rc1
+References: bsc#1099918
+
+The current code decrements the timeout counter i and the end of
+each loop i is incremented, so the check for timeout will always
+be false and hence the timeout mechanism is just a dead code path.
+Potentially, if the RD_READY bit is not set, we could end up in
+an infinite loop.
+
+Fix this so the timeout starts from 1000 and decrements to zero,
+if at the end of the loop i is zero we have a timeout condition.
+
+Detected by CoverityScan, CID#1324008 ("Logically dead code")
+
+Fixes: ccfc97bdb5ae ("[media] smiapp: Add driver")
+
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Signed-off-by: Coly Li <colyli@suse.de>
+
+---
+ drivers/media/i2c/smiapp/smiapp-core.c | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
+index 3b7ace395ee6..e1f8208581aa 100644
+--- a/drivers/media/i2c/smiapp/smiapp-core.c
++++ b/drivers/media/i2c/smiapp/smiapp-core.c
+@@ -1001,7 +1001,7 @@ static int smiapp_read_nvm(struct smiapp_sensor *sensor,
+ if (rval)
+ goto out;
+
+- for (i = 0; i < 1000; i++) {
++ for (i = 1000; i > 0; i--) {
+ rval = smiapp_read(
+ sensor,
+ SMIAPP_REG_U8_DATA_TRANSFER_IF_1_STATUS, &s);
+@@ -1012,11 +1012,10 @@ static int smiapp_read_nvm(struct smiapp_sensor *sensor,
+ if (s & SMIAPP_DATA_TRANSFER_IF_1_STATUS_RD_READY)
+ break;
+
+- if (--i == 0) {
+- rval = -ETIMEDOUT;
+- goto out;
+- }
+-
++ }
++ if (!i) {
++ rval = -ETIMEDOUT;
++ goto out;
+ }
+
+ for (i = 0; i < SMIAPP_NVM_PAGE_SIZE; i++) {
+--
+2.17.1
+
diff --git a/series.conf b/series.conf
index 780b151394..a924c1489f 100644
--- a/series.conf
+++ b/series.conf
@@ -16214,6 +16214,7 @@
patches.drivers/ibmvnic-Introduce-hard-reset-recovery.patch
patches.fixes/ipv6-omit-traffic-class-when-calculating-flow-hash.patch
patches.fixes/e1000e-Ignore-TSYNCRXCTL-when-getting-I219-clock-att.patch
+ patches.suse/0001-media-smiapp-fix-timeout-checking-in-smiapp_read_nvm.patch
patches.drivers/scsi-ipr-new-IOASC-update.patch
# mkp/scsi queue