From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 355D6C43381 for ; Thu, 14 Feb 2019 00:17:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03DE821920 for ; Thu, 14 Feb 2019 00:17:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fjfi.cvut.cz header.i=@fjfi.cvut.cz header.b="bjGFXv+M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404787AbfBNARD (ORCPT ); Wed, 13 Feb 2019 19:17:03 -0500 Received: from mailgw1.fjfi.cvut.cz ([147.32.9.3]:47470 "EHLO mailgw1.fjfi.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733227AbfBNARB (ORCPT ); Wed, 13 Feb 2019 19:17:01 -0500 Received: from localhost (localhost [127.0.0.1]) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTP id 6FDDAAA25C; Thu, 14 Feb 2019 01:16:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fjfi.cvut.cz; s=20151024; t=1550103418; i=@fjfi.cvut.cz; bh=oNnRhOYcpTK47QTd2U41Yt5ssNKI/A5yqljLWMIvhTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bjGFXv+My+TKgFjW+40fpajUBNjyaizEIwSh4K8GOPpnYgZH7RcOCb1W8S48hSpGc inDYl2hlMVX3zTmi4hm8t6CzgBOb8ywXFZZWWD3vQaBE8JKZ9LEIfDGM5UvdpYDXX/ 9lQLxwnC/P9MvBYdEKtyMqVkXj3FC480UDCOxmlM= X-CTU-FNSPE-Virus-Scanned: amavisd-new at fjfi.cvut.cz Received: from mailgw1.fjfi.cvut.cz ([127.0.0.1]) by localhost (mailgw1.fjfi.cvut.cz [127.0.0.1]) (amavisd-new, port 10022) with ESMTP id 3RVHAxhH1poI; Thu, 14 Feb 2019 01:16:53 +0100 (CET) Received: from linux.fjfi.cvut.cz (linux.fjfi.cvut.cz [147.32.5.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTPS id C18F9AA26F; Thu, 14 Feb 2019 01:16:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailgw1.fjfi.cvut.cz C18F9AA26F Received: by linux.fjfi.cvut.cz (Postfix, from userid 1001) id A56126004E; Thu, 14 Feb 2019 01:16:51 +0100 (CET) From: David Kozub To: Jens Axboe , Jonathan Derrick , Scott Bauer , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonas Rabenstein , David Kozub Subject: [PATCH 07/16] block: sed-opal: unify error handling of responses Date: Thu, 14 Feb 2019 01:15:59 +0100 Message-Id: <1550103368-4605-8-git-send-email-zub@linux.fjfi.cvut.cz> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1550103368-4605-1-git-send-email-zub@linux.fjfi.cvut.cz> References: <1550103368-4605-1-git-send-email-zub@linux.fjfi.cvut.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: David Kozub Signed-off-by: Jonas Rabenstein Reviewed-by: Scott Bauer Reviewed-by: Christoph Hellwig Reviewed-by: Jon Derrick --- block/sed-opal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/sed-opal.c b/block/sed-opal.c index 0348fb896a5d..3f368b14efd9 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -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); -- 2.20.1