From patchwork Wed Mar 13 23:50:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 2266911 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 1979DDF215 for ; Wed, 13 Mar 2013 23:52:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934440Ab3CMXve (ORCPT ); Wed, 13 Mar 2013 19:51:34 -0400 Received: from mail-da0-f50.google.com ([209.85.210.50]:44969 "EHLO mail-da0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934451Ab3CMXvO (ORCPT ); Wed, 13 Mar 2013 19:51:14 -0400 Received: by mail-da0-f50.google.com with SMTP id t1so630997dae.9 for ; Wed, 13 Mar 2013 16:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=4W0AbvW99FvOOiT9RW84zSHHRBH03jh5BxgpxNlHOWY=; b=F7IZhuUFUZSz7NUEEX4xRr5FLK6tCk7BHmml4ksSfkLFd7fDOKG6Omb0uovYTX5F5O BqQhI3c+fVK9x05kmVbunPfd7ZkP9AEiiubKFpVPPtTIHHaWuBIbRRSIzJn31O/rn35N doEqRl4aqogqJEea0q+b8aXhHiUiE1zIg2bPA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=4W0AbvW99FvOOiT9RW84zSHHRBH03jh5BxgpxNlHOWY=; b=AKKxLq/bpPxRRXUsIiHwKvGAAN4Pp3e6nO7yx2eNjszEXtgA3yEKAVYJaomiBaO53I H7R/2b1AC1FaMZDAWnyiiEIsv6iF3SufyaH7WLtsYaf97wpgvsebei7b/H/ExHt5lpvA kGjNlNP0O8747krOeon1haIgsv4HV7iJRVmlaClb1p9qHEi7n7PseiM53Ek2v6k530Tg ZaTN9t2zFZccT1Blzx530cLH2jxFmKYdJJgC5HyV3tpq334cuE+qjAWdDwYnon/9OVrO MZBBMyn6kc5/yEcsmLqCz6vR5lkNcVbx0jdUtZgrdh0UPqGBuN/2BH6RYdckzbpG4leh vTaA== X-Received: by 10.68.252.193 with SMTP id zu1mr531317pbc.175.1363218673666; Wed, 13 Mar 2013 16:51:13 -0700 (PDT) Received: from laughingman.mtv.corp.google.com (laughingman.mtv.corp.google.com [172.22.73.99]) by mx.google.com with ESMTPS id kb3sm420254pbc.21.2013.03.13.16.51.12 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Mar 2013 16:51:12 -0700 (PDT) From: Benson Leung To: rydberg@euromail.se, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com Cc: bleung@chromium.org, olofj@chromium.org, djkurtz@chromium.org, dudl@cypress.com Subject: [PATCH 3/4] Input: cyapa - Allow filename to be changed in update_fw Date: Wed, 13 Mar 2013 16:50:50 -0700 Message-Id: <1363218651-22457-4-git-send-email-bleung@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1363218651-22457-1-git-send-email-bleung@chromium.org> References: <1363218651-22457-1-git-send-email-bleung@chromium.org> X-Gm-Message-State: ALoCoQkaXAhaWVZITee79SU7YNKgKdJecHtpdPuA3tqIILhIrqTwF42tytOQ0DUWsnH9/rFidr1b Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Allow the name of the designated firmware to be passed as the argument to update_fw from user space. This will allow user space to specify which firmware to load. Signed-off-by: Benson Leung --- drivers/input/mouse/cyapa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c index e622c25..51e9d44 100644 --- a/drivers/input/mouse/cyapa.c +++ b/drivers/input/mouse/cyapa.c @@ -1180,9 +1180,16 @@ static ssize_t cyapa_update_fw_store(struct device *dev, const char *buf, size_t count) { struct cyapa *cyapa = dev_get_drvdata(dev); - const char *fw_name = CYAPA_FW_NAME; + const char *fw_name; int ret; + /* Do not allow paths that step out of /lib/firmware */ + if (strstr(buf, "../") != NULL) + return -EINVAL; + + fw_name = !strncmp(buf, "1", count) || + !strncmp(buf, "1\n", count) ? CYAPA_FW_NAME : buf; + ret = cyapa_firmware(cyapa, fw_name); if (ret) dev_err(dev, "firmware update failed, %d\n", ret);