Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp3647637ybg; Sun, 7 Jun 2020 06:20:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPqyrS4DudJm0wkBsELndsDKIZcLQ1CW0R5sKsydfb44TMMKn+AOWjyC3e8fqhG56zuLtD X-Received: by 2002:aa7:c4c7:: with SMTP id p7mr18464620edr.271.1591536049564; Sun, 07 Jun 2020 06:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591536049; cv=none; d=google.com; s=arc-20160816; b=vcdB31qFI/ArIp7EsM/IS9G+db17Yj8H8CPTDbL6ORUGQxEjDRRe6SwyzVS6lwlNDt IkTYKj44cD3Wrg/1xasVZ6zKVMCMHvD/JcHEb5Q8AEz1srwLbVdJxJS9Gq+iTI0KdFIb 1LUfZfImna6l3kZsVmMkvIZSH2PwZdzgqKLizqoOB0ckNdkJ+A2TPskjTHnsnz3SiOH5 lcQX12N2AEHMfsHbuOU7Po929jOOBCtOtCqd+sGyy9E03ch1uslICczNQhvJD6AseNZK V27/AUtSZH7y6HOq1KgUGtgtjGHt57a8BUPTspz7ie73axZW03pQD3TebOT94Lihp17L SgaQ== 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=UV/XcomCyEJOnT3Wt8HewpvyWRg13vTzuPyJCP4rUW0=; b=Jv01cLdk6S8kFptmyHNBf7+8WgGCOtuaiRIkbNpbSTIVcxee/z6xeThHH4QjS4nYYn 7LLlwIzoEoEDhU8PM6Gpoct50AGZ+5xTNdSYLwoWWolNHlH6u+YHnPzbNV0jfqsesvda ekd8vkDKa5jov+BLPXX9nR2Ix8eAf3c9NtMEZF3+3Rc+CVgTGDBKpX5gYTcCRypXO4em jGAQwPLopB21ud03Z6/s+C49fKafKSzTuZRlbAlvGgK7agXlYInSc1EdOA59vLVKajiW PVhelnUCSsmYbrJjkdcucobUhYPAlLnfhW3BYkdbklvp1d4Q5DDdAY8Zp1xLuYw/++h6 tbxA== 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 nx24si6647891ejb.615.2020.06.07.06.20.26; Sun, 07 Jun 2020 06:20:49 -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 S1726714AbgFGNPK (ORCPT + 99 others); Sun, 7 Jun 2020 09:15:10 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:17402 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726655AbgFGNOz (ORCPT ); Sun, 7 Jun 2020 09:14:55 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 057D1Vku178108; Sun, 7 Jun 2020 09:14:19 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31gg8008dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 07 Jun 2020 09:14:19 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 057D2CqY179848; Sun, 7 Jun 2020 09:14:19 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 31gg8008cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 07 Jun 2020 09:14:18 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 057DA4sG001486; Sun, 7 Jun 2020 13:14:16 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03fra.de.ibm.com with ESMTP id 31g2s80vtd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 07 Jun 2020 13:14:16 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 057DEDb963897868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 7 Jun 2020 13:14:13 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EAE611C04A; Sun, 7 Jun 2020 13:14:13 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0305B11C058; Sun, 7 Jun 2020 13:14:09 +0000 (GMT) Received: from vajain21-in-ibm-com (unknown [9.85.68.227]) by d06av25.portsmouth.uk.ibm.com (Postfix) with SMTP; Sun, 7 Jun 2020 13:14:08 +0000 (GMT) Received: by vajain21-in-ibm-com (sSMTP sendmail emulation); Sun, 07 Jun 2020 18:44:07 +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 v11 4/6] powerpc/papr_scm: Improve error logging and handling papr_scm_ndctl() Date: Sun, 7 Jun 2020 18:43:37 +0530 Message-Id: <20200607131339.476036-5-vaibhav@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200607131339.476036-1-vaibhav@linux.ibm.com> References: <20200607131339.476036-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-07_03:2020-06-04,2020-06-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 adultscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 impostorscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070096 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' add a debug log unknown 'cmd' values. Cc: "Aneesh Kumar K . V" Cc: Dan Williams Cc: Michael Ellerman Cc: 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