From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932282AbdBIQxM (ORCPT ); Thu, 9 Feb 2017 11:53:12 -0500 Received: from exsmtp01.microchip.com ([198.175.253.37]:38249 "EHLO email.microchip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753287AbdBIQxK (ORCPT ); Thu, 9 Feb 2017 11:53:10 -0500 From: Cyrille Pitchen To: , , CC: , , , , Cyrille Pitchen Subject: [PATCH next 0/2] crypto: atmel-sha: fix error management Date: Thu, 9 Feb 2017 17:51:19 +0100 Message-ID: X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Brightmail-Tracker: H4sIAAAAAAAAC+NgFlrFKsWRWlGSWpSXmKPExsXCxeXDovtu7pwIg471jzu4LO59P89s8frfdBaLOedbWCy6X8lYbHp8jdXi/r2fTBaXd81hs/h2uZndgcNjwa+tLB5bVt5k8th2QNVj85J6j49Pb7F4fN4kF8AWxZqZl5RfkcCasf3cC9aCI4IV5xdZNjCu4uti5OIQEljLKPFtw1X2LkZODjYBQ4m3D46ygtgiAoESC1teMYIUMQtsZpTY9u8dG0hCWMBRov3BDiYQm0VARWLV3q3MIDavgI3Eq57tYDUSAnISN891QsUFJU7OfMICYjMLSEgcfPECLC4koAa0YAUzRH2gxL23S5ggbCeJl0dfQs2xkzg8/SI7hG0vcXbNZnaYmp+7drBC2NoS21/tg7J1JLYd7GeBsG0l9syYCDXTXeLBo+VQtq/ErIcNUDVREg0LTjBNYBSbheTUWUhOXcDItIpR2tnDTzc4TNc1wtnDwFAvNzmjQDc3MTNPLzk/dxMjJOJUdzDe+hd+iFGSg0lJlFe2YE6EEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQnes7OBcoJFqempFWmZOcDYh0kzcXAeYpTg4FES4fUHqeEtLkjMLc5Mh8ifYpSUEudtBEkIgCQySvPgei8xikoJ83aA5HgKUotyM0sg4rcYhTkeMgmx5OXnpUoB3ckABBqMrxjFORiVhHk3gNVn5pXA7XgFtJ4JaP3107NA1pckIqSkGhhnLbqwPFKD87GX6cL41fc98r99/nvX0Cj9RFfG3fmLz3ZpeO24yNGxzCXx5FWeNttip+rdHDsfp/DwZygJnz0gvZrlME+cX/Dcd0cS/+d56PhsDFm4+q22/ZpN2SfUdr8733PTYvMpPeOPXDHia5o9nlSX7YzhO6f/tfh/3IZpp6YnrC6Zv2KREktxRqKhFnNRcSIAgpJWcz0DAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, this series is based on next-20170209. The first patch fixes a bug reported by Dan Carpenter. I didn't put a Fixes tag since the buggy patch is only in linux-next for now so its commit ID is likely to change when entering Linus' tree. It fixes a wrong 'sed' command: many "return -EINVAL;" lines should have been replaced by "return atmel_sha_complete(dd, -EINVAL);" but instead were replaced by direct calls of "atmel_sha_complete(dd, -EINVAL);". My bad, sorry for that! The second patch fixes the way error cases are handled from atmel_sha_start(). For instance, when atmel_sha_update_req() returned an error, atmel_sha_final_req() may have been called after anyway. This issue was present even before my rework of the request queue management, which introduced atmel_sha_start(), so I guess this is a long time issue. Finally, for driver maintainance purpose, I'm preparing other patches to fix the very same and very unlikely issue in both atmel-aes.c and atmel-sha.c: atmel_{aes|sha}_hw_init() may fail, for instance if clk_enable() fails. If so, atmel_{aes|sha}_complete() is called to release the hardware and report the error. Indeed this _complete() function should be called to report and handle any error. However it also incondionnally calls clk_disable(). Hence the following sequence may be buggy: err = atmel_{aes|sha}_hw_init(dd); /* clk_enable() may have failed. */ if (err) return atmel_{aes|sha}_hw_init(dd, err); /* clk_disable() is called anyway. */ I didn't finalize my fixes yet for this unlikely bug. Besides the bug was already present in v4.9 and before, so before introducing atmel_sha_complete(). from atmel_sha_handle_queue(), the older sequence was: err = atmel_sha_hw_init(dd); if (err) goto err1; [...] err1: if (err != -EINPROGRESS) /* done_task will not finish it, so do it here */ atmel_sha_finish_req(req, err); Best regards, Cyrille Cyrille Pitchen (2): crypto: atmel-sha: fix missing "return" instructions crypto: atmel-sha: fix error management in atmel_sha_start() drivers/crypto/atmel-sha.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) -- 2.7.4