diff mbox series

[v4,06/16] block: sed-opal: unify error handling of responses

Message ID 1549054223-12220-7-git-send-email-zub@linux.fjfi.cvut.cz (mailing list archive)
State New, archived
Headers show
Series block: sed-opal: support shadow MBR done flag and write | expand

Commit Message

David Kozub Feb. 1, 2019, 8:50 p.m. UTC
response_get_{string,u64} include error handling for argument resp being
NULL but response_get_token does not handle this.

Make all three of response_get_{string,u64,token} handle NULL resp in
the same way.

Co-authored-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>
---
 block/sed-opal.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Christoph Hellwig Feb. 4, 2019, 2:45 p.m. UTC | #1
On Fri, Feb 01, 2019 at 09:50:13PM +0100, David Kozub wrote:
> response_get_{string,u64} include error handling for argument resp being
> NULL but response_get_token does not handle this.
> 
> Make all three of response_get_{string,u64,token} handle NULL resp in
> the same way.
> 
> Co-authored-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
> Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
> Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
> Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/block/sed-opal.c b/block/sed-opal.c
index e29cb2f445ff..537cd73ea88a 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -702,6 +702,11 @@  static const struct opal_resp_tok *response_get_token(
 {
 	const struct opal_resp_tok *tok;
 
+	if (!resp) {
+		pr_debug("Response is NULL\n");
+		return ERR_PTR(-EINVAL);
+	}
+
 	if (n >= resp->num) {
 		pr_debug("Token number doesn't exist: %d, resp: %d\n",
 			 n, resp->num);