OSDN Git Service

block: sed-opal: unify error handling of responses
authorDavid Kozub <zub@linux.fjfi.cvut.cz>
Thu, 14 Feb 2019 00:15:59 +0000 (01:15 +0100)
committerJens Axboe <axboe@kernel.dk>
Sat, 6 Apr 2019 17:09:12 +0000 (11:09 -0600)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/sed-opal.c

index 0348fb8..3f368b1 100644 (file)
@@ -696,6 +696,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);