Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1687588ybg; Thu, 4 Jun 2020 16:46:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4ZtHqrzzQX/2mqXpMRZ2fLQXweePenfE5z5jM/4ganZ8akVh3sPJKTJuothr46gXsMAUJ X-Received: by 2002:a50:e60b:: with SMTP id y11mr6517077edm.323.1591314369511; Thu, 04 Jun 2020 16:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591314369; cv=none; d=google.com; s=arc-20160816; b=KSTkhS7csCPruuS4L9ncCPRi+pjfnHQPR5+GCAQ+AOIAeI8wNYg6hX3EcTb9dTzFCf W/2n+x4hYO4666m3kiKVaTZHtX+oZRdr6nHvNJ4KD1W3gu7kLbO7DaK1IybevzESwV9H B8lFLwCcO7uJSSod6QWqUmn72yz6q23fPCpGTjuT2EdmJJu/lnrf4iubN+XXh7qZNGRh VvRoo0Bfayo5vbCt+8gD76SaUb4lmfbX4qX8oQe29JxIMMo1ma7fY1qksxkZWz7P/EKA XdaP8FdIVeN9YGyEsBCPyILwgpXlw4isnks7eLJpQVjrTkihtaPVhle4fepWP2MfcTsm gPfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DVwLWw0i2odRfUQNhGxTcWjNVH10r3F3C/fAf/zcvtU=; b=Na7d1SVGRd8QzJs8diZLWYXGoDxwrsuCUcynbWtYJmSWqVVjs4gmqv77xg2Yx5zgQ7 5ymoiorkgsfbHBz4U6LQBs4gBxyDUR1+6TOL5gHXTMwXDagz2VQUpbXpuYb3W2jjDqmP StMyCc/BGqTWpaMn99yly/T+pltuxXm4q3xY0FbiP6KgebaXu8g9Pzm7fENiNEXpcpp4 MIjBkoEPxu36761TnqbdQ6tizfWTnBUQRqPNxG+6HDmlkZxC5i4mBk0XtBU+TTqAJKAN EgUtAGQANiEopoPSmGg5Kc6riUbSGy/9qoSutC9T+1SuJ02NzUeyfhecCgntSqAjUH8A uidQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si2413971eju.407.2020.06.04.16.45.47; Thu, 04 Jun 2020 16:46:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726182AbgFDXm6 (ORCPT + 99 others); Thu, 4 Jun 2020 19:42:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54976 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbgFDXmt (ORCPT ); Thu, 4 Jun 2020 19:42:49 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 054NW3Po090119; Thu, 4 Jun 2020 19:42:14 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31f9dj228v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jun 2020 19:42:14 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 054Ne15X115127; Thu, 4 Jun 2020 19:42:14 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 31f9dj2287-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jun 2020 19:42:14 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 054Neg20028440; Thu, 4 Jun 2020 23:42:11 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 31bf482x7u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jun 2020 23:42:11 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 054NerDv63045936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Jun 2020 23:40:53 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1E83A4057; Thu, 4 Jun 2020 23:42:08 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B6DAA404D; Thu, 4 Jun 2020 23:42:04 +0000 (GMT) Received: from vajain21-in-ibm-com (unknown [9.85.71.124]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Thu, 4 Jun 2020 23:42:04 +0000 (GMT) Received: by vajain21-in-ibm-com (sSMTP sendmail emulation); Fri, 05 Jun 2020 05:12:03 +0530 From: Vaibhav Jain To: linuxppc-dev@lists.ozlabs.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Cc: Vaibhav Jain , Dan Williams , "Aneesh Kumar K . V" , Michael Ellerman , "Oliver O'Halloran" , Santosh Sivaraj , Steven Rostedt , Ira Weiny Subject: [PATCH v10 4/6] powerpc/papr_scm: Improve error logging and handling papr_scm_ndctl() Date: Fri, 5 Jun 2020 05:11:34 +0530 Message-Id: <20200604234136.253703-5-vaibhav@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200604234136.253703-1-vaibhav@linux.ibm.com> References: <20200604234136.253703-1-vaibhav@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-04_13:2020-06-04,2020-06-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 cotscore=-2147483648 mlxscore=0 spamscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006040160 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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' clause of the switch-case block removing a 'return' statement thereby ensuring that value of 'cmd_rc' is always logged when papr_scm_ndctl() returns. Cc: "Aneesh Kumar K . V" Cc: Dan Williams Cc: Michael Ellerman Cc: Ira Weiny Signed-off-by: Vaibhav Jain --- Changelog: v9..v10 * New patch in the series --- arch/powerpc/platforms/pseries/papr_scm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c index 0c091622b15e..6512fe6a2874 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,12 +386,13 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, break; default: - return -EINVAL; + dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd); + *cmd_rc = -EINVAL; } dev_dbg(&p->pdev->dev, "returned with cmd_rc = %d\n", *cmd_rc); - return 0; + return *cmd_rc; } static ssize_t flags_show(struct device *dev, -- 2.26.2