diff mbox

omap-crypto - fix kernel oops and output buffer update

Message ID 1522164573-12259-1-git-send-email-francis.lebourse@sfr.fr (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show

Commit Message

Francis Le Bourse March 27, 2018, 3:29 p.m. UTC
Hi Tero,

> I have a couple of additional comments, but can't add them as the patch
> content is an attachment (like, I would not add the WARN_ON.) Overall,
> the issue you have found is a legitimate problem, and should be fixed.

I have used WARN_ON() to have some very visible output, I agree it is not
necessary. This error was possibly a side effect of the &dd->out_sgl aes
bug and I haven't seen it since I have fixed the latter.


Signed-off-by: Francis Le Bourse <francis.lebourse@sfr.fr>
---
 drivers/crypto/omap-crypto.c       | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Herbert Xu March 30, 2018, 5:18 p.m. UTC | #1
Francis Le Bourse <francis.lebourse@sfr.fr> wrote:
> Hi Tero,
> 
>> I have a couple of additional comments, but can't add them as the patch
>> content is an attachment (like, I would not add the WARN_ON.) Overall,
>> the issue you have found is a legitimate problem, and should be fixed.
> 
> I have used WARN_ON() to have some very visible output, I agree it is not
> necessary. This error was possibly a side effect of the &dd->out_sgl aes
> bug and I haven't seen it since I have fixed the latter.

When you resubmit a patch please indicate it in the Subject, e.g.,
with a v2, v3, and so on.  Also please retain the complete patch
description on each occasion.

Thanks,
diff mbox

Patch

diff --git a/drivers/crypto/omap-crypto.c b/drivers/crypto/omap-crypto.c
index 2c42e4b..fbf5a00 100644
--- a/drivers/crypto/omap-crypto.c
+++ b/drivers/crypto/omap-crypto.c
@@ -161,24 +161,24 @@  void omap_crypto_cleanup(struct scatterlist *sg, struct scatterlist *orig,
 			 int offset, int len, u8 flags_shift,
 			 unsigned long flags)
 {
-	void *buf;
-	int pages;
-
 	flags >>= flags_shift;
-	flags &= OMAP_CRYPTO_COPY_MASK;
 
-	if (!flags)
-		return;
+	if (flags & OMAP_CRYPTO_DATA_COPIED) {
+		void *buf;
+		int pages;
 
-	buf = sg_virt(sg);
-	pages = get_order(len);
+		if (WARN_ON(!sg_page(sg)))
+			return;
 
-	if (orig && (flags & OMAP_CRYPTO_COPY_MASK))
-		scatterwalk_map_and_copy(buf, orig, offset, len, 1);
+		buf = sg_virt(sg);
+		pages = get_order(len);
 
-	if (flags & OMAP_CRYPTO_DATA_COPIED)
+		if (orig)
+			scatterwalk_map_and_copy(buf, orig, offset, len, 1);
 		free_pages((unsigned long)buf, pages);
-	else if (flags & OMAP_CRYPTO_SG_COPIED)
+	}
+
+	if (flags & OMAP_CRYPTO_SG_COPIED)
 		kfree(sg);
 }
 EXPORT_SYMBOL_GPL(omap_crypto_cleanup);