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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 00042C433DF for ; Mon, 8 Jun 2020 16:09:55 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 777992063A for ; Mon, 8 Jun 2020 16:09:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 777992063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49gdW46qf4zDqRH for ; Tue, 9 Jun 2020 02:09:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=ira.weiny@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49gdSw4wk3zDqN2 for ; Tue, 9 Jun 2020 02:07:53 +1000 (AEST) IronPort-SDR: 4b/rlfDItlhQoPq8uEIOljBMH1mmHDx9S8WIoLccCbYELqhBviZtBl4nOU8wg7xo9K2hNQjff8 psBctb0pcppg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 09:07:48 -0700 IronPort-SDR: nj6H1nx1dfa6r0w/NIMfuEQlWaDAdrMcRgCbwY9lcFrLKtz9i47DJxhXA9oOgKYhQw47y86wAk mNLDIM8YSp8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="258727589" Received: from iweiny-desk2.sc.intel.com ([10.3.52.147]) by fmsmga007.fm.intel.com with ESMTP; 08 Jun 2020 09:07:48 -0700 Date: Mon, 8 Jun 2020 09:07:48 -0700 From: Ira Weiny To: Vaibhav Jain Subject: Re: [PATCH v11 4/6] powerpc/papr_scm: Improve error logging and handling papr_scm_ndctl() Message-ID: <20200608160747.GA2936401@iweiny-DESK2.sc.intel.com> References: <20200607131339.476036-1-vaibhav@linux.ibm.com> <20200607131339.476036-5-vaibhav@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200607131339.476036-5-vaibhav@linux.ibm.com> User-Agent: Mutt/1.11.1 (2018-12-01) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Santosh Sivaraj , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Steven Rostedt , Oliver O'Halloran , "Aneesh Kumar K . V" , Dan Williams , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sun, Jun 07, 2020 at 06:43:37PM +0530, Vaibhav Jain wrote: > Since papr_scm_ndctl() can be called from outside papr_scm, its > exposed to the possibility of receiving NULL as value of 'cmd_rc' > argument. This patch updates papr_scm_ndctl() to protect against such > possibility by assigning it pointer to a local variable in case cmd_rc > == NULL. > > Finally the patch also updates the 'default' add a debug log unknown > 'cmd' values. > > Cc: "Aneesh Kumar K . V" > Cc: Dan Williams > Cc: Michael Ellerman > Cc: Ira Weiny Reviewed-by: Ira Weiny > Signed-off-by: Vaibhav Jain > --- > Changelog: > > v10..v11: > * Instead of returning *cmd_rd just return '0' in case nd_cmd is > handled. In case of unknown nd-cmd return -EINVAL > [ Ira and Dan Williams ] > * Updated patch description. > > v9..v10 > * New patch in the series > --- > arch/powerpc/platforms/pseries/papr_scm.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c > index 0c091622b15e..692ad3d79826 100644 > --- a/arch/powerpc/platforms/pseries/papr_scm.c > +++ b/arch/powerpc/platforms/pseries/papr_scm.c > @@ -355,11 +355,16 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > { > struct nd_cmd_get_config_size *get_size_hdr; > struct papr_scm_priv *p; > + int rc; > > /* Only dimm-specific calls are supported atm */ > if (!nvdimm) > return -EINVAL; > > + /* Use a local variable in case cmd_rc pointer is NULL */ > + if (!cmd_rc) > + cmd_rc = &rc; > + > p = nvdimm_provider_data(nvdimm); > > switch (cmd) { > @@ -381,6 +386,7 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, > break; > > default: > + dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd); > return -EINVAL; > } > > -- > 2.26.2 >