Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150AbbH1PYn (ORCPT ); Fri, 28 Aug 2015 11:24:43 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:34148 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787AbbH1PYl (ORCPT ); Fri, 28 Aug 2015 11:24:41 -0400 Subject: Re: [PATCH v2 4/4] remoteproc: debugfs: Add ability to boot remote processor using debugfs To: Lee Jones References: <1440757911-9120-1-git-send-email-lee.jones@linaro.org> <1440757911-9120-5-git-send-email-lee.jones@linaro.org> CC: , , , , , Ludovic Barre From: Nathan Lynch Message-ID: <55E07CE2.2050704@mentor.com> Date: Fri, 28 Aug 2015 10:23:14 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1440757911-9120-5-git-send-email-lee.jones@linaro.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1551 Lines: 52 On 08/28/2015 05:31 AM, Lee Jones wrote: > +static ssize_t rproc_state_write(struct file *filp, const char __user *userbuf, > + size_t count, loff_t *ppos) > +{ > + struct rproc *rproc = filp->private_data; > + char buf[2]; > + int ret; > + > + ret = copy_from_user(buf, userbuf, 1); > + if (ret) > + return -EFAULT; > + > + switch (buf[0]) { > + case '0': > + rproc_shutdown(rproc); > + break; > + case '1': > + ret = rproc_boot(rproc); > + if (ret) > + dev_warn(&rproc->dev, "Boot failed: %d\n", ret); > + break; > + default: > + dev_err(&rproc->dev, "Unrecognised option: %x\n", buf[1]); > + return -EINVAL; This prints uninitialized kernel stack contents instead of what was copied from user space. Is the dev_err statement really necessary anyway? > + } > + > + return count; > +} If rproc_boot fails, that should be reflected in the syscall result. This interface is essentially exposing the remoteproc->power refcount to user space; is that okay? Seems like it makes it easy to underflow remoteproc->power through successive shutdown calls. The other debugfs interface in remoteproc that has a write method (recovery) accepts more expressive string commands as opposed to 0/1. It would be more consistent for this interface to take commands such as "boot" and "shutdown" IMO. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/