Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3471443imu; Sun, 11 Nov 2018 15:52:39 -0800 (PST) X-Google-Smtp-Source: AJdET5dtTRbKy8Gc5aWDUfKQ0g5h7c86YPCubnOE3C7ZExFmpZ8/dajzLW5WpivYmOyJfEzOFUMV X-Received: by 2002:a62:6d07:: with SMTP id i7-v6mr17775183pfc.146.1541980359829; Sun, 11 Nov 2018 15:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980359; cv=none; d=google.com; s=arc-20160816; b=cNgXT3fr2nkiJ8xkBYRTkPnXBCK1WfX8ehgwy66Hiphr/RbTSlxQuPlDrmqZ5VGdpG 4YeBSMOo1chjHzL8w6WLZlH5EhMBC5K8qQ6+ox5/Ex4E054vro3o7gNYzCQK0epZsgmf VYpvQmRzuIsBM/jq8knBzWmqgdP4F3vKBXkE+0e5PrUMR8gtHFB5iFBJCrJOGkU86LqD gFQmyOiMLYepx0nYx1DthpR34kb6SAvWcGZ8/uZ4wlcu2lq1iYEliMxzexnLTZh92Ug3 6SxQlv+0GANE0SuJWcJ6/WQQzWkagfzig/TSBp6jxiP7gEne8RSiWC+f7LVuoVM0rjXX ejGg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mpbrJHZKdf6c3FPvuvYt6DurBGokis3C1QTNFtpBbIo=; b=A1D2jGN9tz7D5meGVywCdPIvuui98AYa0+Uveu01vFtNiwfPkE64bcKDU8KxyzrokP 0kSepFPuPGoAhyE3ZBpmAxqyz20o8mHaTUH48GHc5js9kZlGSVPzBqZrYnzsFYuNm2i9 8Lu0A2PuhJwGKEpx+wdj+nUjHs9Y6L/ZckFpsSNsT793Ta/9sHCSPtIsVGnFXO7eBETk wjBwdqmdVofWs6O0fvNfFuEBhdd2Ha4278HX9vl7glR+c6LeiRfvkmWkrDDYj5PHoE8I CQnmS18hnoe+2WOkCAmceHtJKSmQdFR+cSskca1g/p3DPijrIq3XsMJGC41tftishSVF jmJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WkG6W9fD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24-v6si13136996pgb.50.2018.11.11.15.52.24; Sun, 11 Nov 2018 15:52:39 -0800 (PST) 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=WkG6W9fD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732938AbeKLJmU (ORCPT + 99 others); Mon, 12 Nov 2018 04:42:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:37302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732830AbeKLIS3 (ORCPT ); Mon, 12 Nov 2018 03:18:29 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2F1421527; Sun, 11 Nov 2018 22:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975313; bh=HsCTycn7vNpwmWFPtxqiTUZjcl3N2nqyOReAXBP/kns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WkG6W9fD35qTPf8dYNFmV9ZV+hS2mgInAoz6xS7LL7Eoz/7ZfTkxiAD8xuPPgqriU P3rdFZ+gFTqwHu1OXBFEPBl8hDWmflumqgJFa3ULmexXkaZpfTmqCveed4Gn7DaRPv b25zMtGK6gZsmsfSvNIqpkCB1GURoDZOyWwZ6wZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.19 298/361] media: cec: integrate cec_validate_phys_addr() in cec-api.c Date: Sun, 11 Nov 2018 14:20:45 -0800 Message-Id: <20181111221657.263533278@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans Verkuil commit e81bff39489a06384822bb38ce7a59f9e365bbe9 upstream. 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: Greg Kroah-Hartman --- drivers/media/cec/cec-api.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) --- a/drivers/media/cec/cec-api.c +++ b/drivers/media/cec/cec-api.c @@ -101,6 +101,23 @@ static long cec_adap_g_phys_addr(struct 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) { @@ -112,7 +129,7 @@ static long cec_adap_s_phys_addr(struct 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);