From patchwork Thu May 18 13:50:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9734473 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 59604601A1 for ; Thu, 18 May 2017 13:51:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48EBF286B8 for ; Thu, 18 May 2017 13:51:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DD09286E7; Thu, 18 May 2017 13:51:46 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 C7EB9286B8 for ; Thu, 18 May 2017 13:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755387AbdERNvo (ORCPT ); Thu, 18 May 2017 09:51:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43886 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751486AbdERNvo (ORCPT ); Thu, 18 May 2017 09:51:44 -0400 Received: from localhost (LFbn-1-12060-104.w90-92.abo.wanadoo.fr [90.92.122.104]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 51EA1B79; Thu, 18 May 2017 13:51:43 +0000 (UTC) From: Greg Kroah-Hartman To: mchehab@s-opensource.com, alan@linux.intel.com Cc: Dan Carpenter , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Greg Kroah-Hartman Subject: [PATCH 10/13] staging: media: atomisp: one char read beyond end of string Date: Thu, 18 May 2017 15:50:19 +0200 Message-Id: <20170518135022.6069-11-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170518135022.6069-1-gregkh@linuxfoundation.org> References: <20170518135022.6069-1-gregkh@linuxfoundation.org> 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 From: Dan Carpenter We should verify that "ix < max_len" before we test whether we have reached the NUL terminator. Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2") Reported-by: David Binderman Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../pci/atomisp2/css2400/hive_isp_css_include/string_support.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/string_support.h b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/string_support.h index 568631698a3d..74b5a1c7ac9a 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/string_support.h +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/string_support.h @@ -72,9 +72,8 @@ static size_t strnlen_s( return 0; } - for (ix=0; - ((src_str[ix] != '\0') && (ix< max_len)); - ++ix) /*Nothing else to do*/; + for (ix = 0; ix < max_len && src_str[ix] != '\0'; ix++) + ; /* On Error, it will return src_size == max_len*/ return ix;