From patchwork Mon May 25 16:48:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 187194 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp5097053ilb; Mon, 25 May 2020 09:48:20 -0700 (PDT) X-Received: by 2002:a2e:9648:: with SMTP id z8mr11412575ljh.451.1590425300705; Mon, 25 May 2020 09:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590425300; cv=none; d=google.com; s=arc-20160816; b=L72DswD2XCC+SvdFPiWnjGEPI8YoilM/6m9zvU9Y3rz0c/XELW6V9OKynlQpLDXGh/ 3o0tTjUZ+/5MCxGLRnaGgx2WOJ9MO6cug3xNbqULGF+0WQJf5mPidaEB7UGvVJxUTxJS A/2/fKwxB4pz1pRSsI8KXuJvUi+7JCS7hg6ZphL4kk/2BlmhDFl6f9TYOlMiAbGqgnqE Fr+47web7PCIWSkCONd6MO5G62VS6iPEkfOjOqGxLNFBGmIw5zZ41qBIC5bE8dKrfvJs tsyYlxk/MKlS7GVjrKXDAgGNZAFjVA/LrDBqHZqLofGS4Umb7ltvxAVL8mHEQfYERSkn oLaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hLLac1fRuRW93cBHaKE0yJPxIw5p9I3En46VkMcc2XY=; b=Bw95qsFX8Cr5/rJ7NBLl9djZEkciVG1Nqi5j6Tcp+gLNK8eNAyQe16Oa+HeXDfF6Vm kW4FWGzGJ7XdiuV722XfVElqbo8neAujnghWgdo0HMHibjs/iqS6B+MD7ZUiEmjfQIhA MG+/+ro4rytm4rRXDQMnJ8Q40Ks0yiAjM9cydhZ7FYo8uEV5tM1ziJD4ArK8TO/YkEUo lLAY4kftzlD0ktP9rdHGY9XN+Pa8qfSJF0FrCGuizK0zU72okr+t38tvRUZ7WKDrd5SI VVNlYyNNXkl54GxrnNkcKxO5W6MsQcHurkqcwTkbTkp6HA59OHZ9Q6boXC0Yd7WHtrPx q8eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vkWuIn0z; spf=pass (google.com: domain of dmitry.baryshkov@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dmitry.baryshkov@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m28sor8915175ljc.10.2020.05.25.09.48.20 for (Google Transport Security); Mon, 25 May 2020 09:48:20 -0700 (PDT) Received-SPF: pass (google.com: domain of dmitry.baryshkov@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vkWuIn0z; spf=pass (google.com: domain of dmitry.baryshkov@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dmitry.baryshkov@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hLLac1fRuRW93cBHaKE0yJPxIw5p9I3En46VkMcc2XY=; b=vkWuIn0zGI0GsGTu8GD+A30tBGc9GakWacPqWoPMXYMbqMx1/wvSjxaULu207Z6Rg4 g2FQDU1uyFBksSoK9gF+6Qt3/RNkGp9RGJWm4mmJu7/XWA2hTYHtmaPX1xnQb/2M+GGr dJxg1ojN6CyvHUDAYpV41QFxzyfkLW/aX+c+GuosLe1rvtpm8kyffGPnf6pFAX9VUqXV IZAo1EF9AYBKrOv+e2d5oxLJdZaW6cklQoMymW2no3XypppgTVRbd4poYHviuTDecnfC P8D79U6q/vwRJ4yn9GRKZ0IifnmLDXyPdg3OFLAwH6X9PsRHC0Nwmux8dhutxBvZ0PyY crzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hLLac1fRuRW93cBHaKE0yJPxIw5p9I3En46VkMcc2XY=; b=U98CfkivaGHOBTvku4iwkU1fAn/ezW9yahQlTJ4YDAm3KAJ66GAJTvuhU0Z7PLAI6K GkBa6cBfIQS1obCcLZBSOrJCS9QIfrHoQ4o6a8zrA09MAiHO9kOumtDSUQhd1iKBuTkp 6Mv3brGIfZwgKoEIMW8LbeLHClsjMgVEjFtXg86dI3wWWT1lzNGNrGGOemCOKeAoUMxK DM/H7shxjz/sbCx/bq9iGIpOckKOoRHig9wxG2f3/PToB5LlwSuCWWc0iteM7yU2pUCf c7CDaAd9CaYpuUWe8C0kk1UmjFcWAT4JEz53HDSGokshBepBf4/A5UxsnTIxtsKdVQ3m pxwA== X-Gm-Message-State: AOAM530R1Ymzfvie6lGDcFuArhniythOeb1HwCzTSxvNNiN9mR+JcdSc fAr8ARBeRWKCnimyqIo8ycKb0yfH X-Google-Smtp-Source: ABdhPJyX3HhRY0EYbLe4KxnpTY7caK05udU0l6Usk0hAMdvcyCn2ESccsrAMR3FbZDxf93aUgNd1Kg== X-Received: by 2002:a2e:890e:: with SMTP id d14mr14198060lji.216.1590425300344; Mon, 25 May 2020 09:48:20 -0700 (PDT) Return-Path: Received: from lothlann.lan ([188.162.64.24]) by smtp.gmail.com with ESMTPSA id y21sm2914337ljg.48.2020.05.25.09.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 09:48:19 -0700 (PDT) From: Dmitry Baryshkov To: linux-arm-msm@vger.kernel.org Cc: Andy Gross , Bjorn Andersson , patches@linaro.org, linaro-kernel@lists.linaro.org Subject: [PATCH 2/4] soc: qcom: socinfo: fix printing of pmic_model Date: Mon, 25 May 2020 19:48:15 +0300 Message-Id: <20200525164817.2938638-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200525164817.2938638-1-dmitry.baryshkov@linaro.org> References: <20200525164817.2938638-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Print sensible string instead of just "(null)" for unknown PMIC models. Also as we are at it, do not let debugfs handler access past pmic_models array. Signed-off-by: Dmitry Baryshkov --- drivers/soc/qcom/socinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.26.2 Reviewed-by: Bjorn Andersson diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index 0e6adf1161c0..41f48c3447cc 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -269,7 +269,10 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p) if (model < 0) return -EINVAL; - seq_printf(seq, "%s\n", pmic_models[model]); + if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model]) + seq_printf(seq, "%s\n", pmic_models[model]); + else + seq_printf(seq, "unknown (%d)\n", model); return 0; }