linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Escande <thierry.escande@collabora.com>
To: Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/8] [media] s5p-jpeg: Handle parsing error in s5p_jpeg_parse_hdr()
Date: Tue, 27 Jun 2017 18:08:49 +0200	[thread overview]
Message-ID: <1498579734-1594-4-git-send-email-thierry.escande@collabora.com> (raw)
In-Reply-To: <1498579734-1594-1-git-send-email-thierry.escande@collabora.com>

This patch modifies the s5p_jpeg_parse_hdr() function so it only
modifies the passed s5p_jpeg_q_data structure if the jpeg header parsing
is successful.

Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
---
 drivers/media/platform/s5p-jpeg/jpeg-core.c | 38 ++++++++++++++++-------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 0d935f5..df3e5ee 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1206,22 +1206,9 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
 			break;
 		}
 	}
-	result->w = width;
-	result->h = height;
-	result->sos = sos;
-	result->dht.n = n_dht;
-	while (n_dht--) {
-		result->dht.marker[n_dht] = dht[n_dht];
-		result->dht.len[n_dht] = dht_len[n_dht];
-	}
-	result->dqt.n = n_dqt;
-	while (n_dqt--) {
-		result->dqt.marker[n_dqt] = dqt[n_dqt];
-		result->dqt.len[n_dqt] = dqt_len[n_dqt];
-	}
-	result->sof = sof;
-	result->sof_len = sof_len;
-	result->size = result->components = components;
+
+	if (notfound || !sos)
+		return false;
 
 	switch (subsampling) {
 	case 0x11:
@@ -1240,7 +1227,24 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
 		return false;
 	}
 
-	return !notfound && sos;
+	result->w = width;
+	result->h = height;
+	result->sos = sos;
+	result->dht.n = n_dht;
+	while (n_dht--) {
+		result->dht.marker[n_dht] = dht[n_dht];
+		result->dht.len[n_dht] = dht_len[n_dht];
+	}
+	result->dqt.n = n_dqt;
+	while (n_dqt--) {
+		result->dqt.marker[n_dqt] = dqt[n_dqt];
+		result->dqt.len[n_dqt] = dqt_len[n_dqt];
+	}
+	result->sof = sof;
+	result->sof_len = sof_len;
+	result->size = result->components = components;
+
+	return true;
 }
 
 static int s5p_jpeg_querycap(struct file *file, void *priv,
-- 
2.7.4

  parent reply	other threads:[~2017-06-27 16:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170627160906epcas4p369a67fdb1b8f6898a1f1b4ddb7927995@epcas4p3.samsung.com>
2017-06-27 16:08 ` [PATCH v3 0/8] [media] s5p-jpeg: Various fixes and improvements Thierry Escande
2017-06-27 16:08   ` [PATCH v3 1/8] [media] s5p-jpeg: Call jpeg_bound_align_image after qbuf Thierry Escande
2017-06-29 12:03     ` Andrzej Pietrasiewicz
2017-06-27 16:08   ` [PATCH v3 2/8] [media] s5p-jpeg: Correct WARN_ON statement for checking subsampling Thierry Escande
2017-06-29 12:03     ` Andrzej Pietrasiewicz
2017-06-27 16:08   ` Thierry Escande [this message]
2017-06-29 12:04     ` [PATCH v3 3/8] [media] s5p-jpeg: Handle parsing error in s5p_jpeg_parse_hdr() Andrzej Pietrasiewicz
2017-06-27 16:08   ` [PATCH v3 4/8] [media] s5p-jpeg: Don't use temporary structure in s5p_jpeg_buf_queue Thierry Escande
2017-06-29 12:04     ` Andrzej Pietrasiewicz
2017-06-29 20:12     ` Jacek Anaszewski
2017-06-27 16:08   ` [PATCH v3 5/8] [media] s5p-jpeg: Split s5p_jpeg_parse_hdr() Thierry Escande
2017-06-29 12:04     ` Andrzej Pietrasiewicz
2017-06-27 16:08   ` [PATCH v3 6/8] [media] s5p-jpeg: Decode 4:1:1 chroma subsampling format Thierry Escande
2017-06-29 12:04     ` Andrzej Pietrasiewicz
2017-06-27 16:08   ` [PATCH v3 7/8] [media] s5p-jpeg: Add support for resolution change event Thierry Escande
2017-06-29 12:04     ` Andrzej Pietrasiewicz
2017-06-27 16:08   ` [PATCH v3 8/8] [media] s5p-jpeg: Add stream error handling for Exynos5420 Thierry Escande
2017-06-29 12:05     ` Andrzej Pietrasiewicz
2017-06-29 12:02   ` [PATCH v3 0/8] [media] s5p-jpeg: Various fixes and improvements Andrzej Pietrasiewicz
2017-06-29 20:13   ` Jacek Anaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498579734-1594-4-git-send-email-thierry.escande@collabora.com \
    --to=thierry.escande@collabora.com \
    --cc=andrzej.p@samsung.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).