From patchwork Wed Jul 6 08:49:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hans Verkuil (hansverk)" X-Patchwork-Id: 9215707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81B5A607D9 for ; Wed, 6 Jul 2016 08:49:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72881285E0 for ; Wed, 6 Jul 2016 08:49:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 673FB28602; Wed, 6 Jul 2016 08:49:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47490285E0 for ; Wed, 6 Jul 2016 08:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750780AbcGFIte (ORCPT ); Wed, 6 Jul 2016 04:49:34 -0400 Received: from aer-iport-4.cisco.com ([173.38.203.54]:5006 "EHLO aer-iport-4.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752112AbcGFIta (ORCPT ); Wed, 6 Jul 2016 04:49:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1379; q=dns/txt; s=iport; t=1467794970; x=1469004570; h=to:cc:from:subject:message-id:date:mime-version: content-transfer-encoding; bh=GMy+X3MadR2/44avV3spXv8WcsNj4E9xLue++h7lefw=; b=BAqCINVMWJ41suIux4NUdnr5noKKZiAnFud9nPYrLZmIJR9ux8m1NOHZ oOKAwffliUZbrD15K80061JMxfOHa1yVaz1WONh0Kspbpx1FWIR4MT7/+ BGZTseCOgFZZu4GHUVY046ihHehbwqYqy68U4cDyM/aD4SWMN7tub4OOQ o=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CoBAB+xXxX/xbLJq1dhRC3OYQGhhiBe?= =?us-ascii?q?QEBAQEBAWYnhHYEUQE1AgUWCwILAwIBAgFLDQYCAogsq22PewEBAQEBAQQBAQE?= =?us-ascii?q?BI4EBhSaMDoJaAQSOBIsPjkeJS4VdApAKVIIIHIFOOjKIcgEBAQ?= X-IronPort-AV: E=Sophos;i="5.28,318,1464652800"; d="scan'208";a="638396230" Received: from aer-iport-nat.cisco.com (HELO aer-core-1.cisco.com) ([173.38.203.22]) by aer-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jul 2016 08:49:27 +0000 Received: from [10.47.79.81] ([10.47.79.81]) (authenticated bits=0) by aer-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id u668nQLd003518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 6 Jul 2016 08:49:27 GMT To: linux-media Cc: Dan Carpenter From: Hans Verkuil Subject: [PATCH] cec-funcs.h: add length checks Message-ID: <577CC616.7060002@cisco.com> Date: Wed, 6 Jul 2016 10:49:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 MIME-Version: 1.0 X-Authenticated-User: hansverk Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add msg->len sanity checks to fix static checker warning: include/linux/cec-funcs.h:1154 cec_ops_set_osd_string() warn: setting length 'msg->len - 3' to negative one Signed-off-by: Hans Verkuil Reported-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/cec-funcs.h b/include/linux/cec-funcs.h index 19486009..8d217ce 100644 --- a/include/linux/cec-funcs.h +++ b/include/linux/cec-funcs.h @@ -788,7 +788,7 @@ static inline void cec_msg_set_timer_program_title(struct cec_msg *msg, static inline void cec_ops_set_timer_program_title(const struct cec_msg *msg, char *prog_title) { - unsigned int len = msg->len - 2; + unsigned int len = msg->len > 2 ? msg->len - 2 : 0; if (len > 14) len = 14; @@ -1167,7 +1167,7 @@ static inline void cec_ops_set_osd_string(const struct cec_msg *msg, __u8 *disp_ctl, char *osd) { - unsigned int len = msg->len - 3; + unsigned int len = msg->len > 3 ? msg->len - 3 : 0; *disp_ctl = msg->msg[2]; if (len > 13) @@ -1192,7 +1192,7 @@ static inline void cec_msg_set_osd_name(struct cec_msg *msg, const char *name) static inline void cec_ops_set_osd_name(const struct cec_msg *msg, char *name) { - unsigned int len = msg->len - 2; + unsigned int len = msg->len > 2 ? msg->len - 2 : 0; if (len > 14) len = 14;