Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3335239yba; Mon, 6 May 2019 22:42:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjsh1Nq+a85XYH2lDTiK0b258TuO4xpy80hJsst3g68fDmgvhFA9drdaW5Yi9ymQ6TJWx0 X-Received: by 2002:a62:b508:: with SMTP id y8mr37294257pfe.113.1557207734688; Mon, 06 May 2019 22:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557207734; cv=none; d=google.com; s=arc-20160816; b=HDrZ4/AX+RIs206+EvI6f+BZrk3pA86fE9Xd/TSnvGXVlrp67xQgRSnYE1XC6lW7pF tB8K5CRc9GlypU+A0yx3KFZfd7IqP3GdAbdgw/TwXlqPfTA8Oa/eyV4QN5X9ZieYuYGm GeiEfpGZlCHXtskxejIBuu/ilnU2gznXkCZOL9QyIPx0FROjYEeKmKyhAMJMy5ZfYeEa nYte6OiLJcWHCm3mdfhShYer0dhCkwSbEJP5C8gyALkkRuYHTUhirPw9eALGUElyo4NS 7gAGoVWoAQ1ew0sstZAgerSjF2kAGcwXAjKHXxhl1yKuXFyutSR1bOba9A8feplArKpe 794A== 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 :dkim-signature; bh=72xR1qqaIuhZ2OZa01/2UXO+Li+RQh4AFHfAQU2N7e8=; b=tIFXnWrP3+iUty9UdLve0FyLMMGHDex6LU2EfzbYf50AmALlKw2aY75TuBHOQogozH cf90hRcxP2iM+A6ERsOtnPdRPrfw3ec4403T94HHLmrXOmUBU57QankRjVhila1anAWs QllUdORw5mrxQbWASO72UVN70puTOBQajGT7FYfipkUe4+5FZ+e9jMlwoP7tmNwpOwW+ rFYwYPvAmfMxjrsIPhziPfevkreiyPpyRfYrQDGeGJjiqsHvx26aZezcJloIIlAQXgQ9 Ft1y6tuXRBVCyxr9R2FI9KgrZ5EWoAvNNGtjIGU2bsAq0MneB93W0HfGADd6SSgTwafZ auEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QZsvKgMU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ca10si6076714plb.172.2019.05.06.22.41.59; Mon, 06 May 2019 22:42:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QZsvKgMU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729004AbfEGFkC (ORCPT + 99 others); Tue, 7 May 2019 01:40:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:59422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728618AbfEGFjz (ORCPT ); Tue, 7 May 2019 01:39:55 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52A5E214AE; Tue, 7 May 2019 05:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557207595; bh=zfyqsegOSabOX3b11HPuSPLvhWLqVAZAvUI1iZD029I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZsvKgMU3GWbyamH98S51Kzh7kYhvBhF8LM6ADoiYMAufE81Mm4NqOYt1VZ2NsDXp ctO2Pr2KbGwMaE4ro3cgP49Rtyz8yQ/3eJzk9EdO7eV7vkVmz+nKexbuUu/yrfyCS1 TFsXxfZQ3RlCC4Qsl6PnRr9+aIrDZofyfXSbpv8E= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 44/95] media: cec: integrate cec_validate_phys_addr() in cec-api.c Date: Tue, 7 May 2019 01:37:33 -0400 Message-Id: <20190507053826.31622-44-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190507053826.31622-1-sashal@kernel.org> References: <20190507053826.31622-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Verkuil [ Upstream commit e81bff39489a06384822bb38ce7a59f9e365bbe9 ] The cec_phys_addr_validate() function will be moved to V4L2, so use a simplified variant of that function in cec-api.c. cec now no longer calls cec_phys_addr_validate() and it can be safely moved to V4L2. Signed-off-by: Hans Verkuil Cc: # for v4.17 and up Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/cec/cec-api.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c index a079f7fe018c..21a5f45e0259 100644 --- a/drivers/media/cec/cec-api.c +++ b/drivers/media/cec/cec-api.c @@ -113,6 +113,23 @@ static long cec_adap_g_phys_addr(struct cec_adapter *adap, return 0; } +static int cec_validate_phys_addr(u16 phys_addr) +{ + int i; + + if (phys_addr == CEC_PHYS_ADDR_INVALID) + return 0; + for (i = 0; i < 16; i += 4) + if (phys_addr & (0xf << i)) + break; + if (i == 16) + return 0; + for (i += 4; i < 16; i += 4) + if ((phys_addr & (0xf << i)) == 0) + return -EINVAL; + return 0; +} + static long cec_adap_s_phys_addr(struct cec_adapter *adap, struct cec_fh *fh, bool block, __u16 __user *parg) { @@ -124,7 +141,7 @@ static long cec_adap_s_phys_addr(struct cec_adapter *adap, struct cec_fh *fh, if (copy_from_user(&phys_addr, parg, sizeof(phys_addr))) return -EFAULT; - err = cec_phys_addr_validate(phys_addr, NULL, NULL); + err = cec_validate_phys_addr(phys_addr); if (err) return err; mutex_lock(&adap->lock); -- 2.20.1