Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2265227ybl; Thu, 19 Dec 2019 10:40:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzKdGwc7Mz7bP2FFnKeX631OJ6TOapEbY3IdxVzhHufXdgnJ5ZgExMZpN06Vx1p1Ar8IPNM X-Received: by 2002:a05:6830:1c85:: with SMTP id v5mr10764576otf.35.1576780831523; Thu, 19 Dec 2019 10:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576780831; cv=none; d=google.com; s=arc-20160816; b=hgFXZx9dlZGW8jI15aycMRrdGSYfxaoJPUXEfP8hJT7I05sq2d+tbIbbrSs8uzRb5a fLBEQgbSESo26UoU5hJDlqgqaHph4qzHp0FjHvGYOVPT8ks4ZRHnNqMnx9/D/9AnFBhC 5jKQj2MdRd4WlYd9Cl6OBNg4cqLV5/tMCCU4rYgyE1hO+QQWH/PE9DFPUcNAZ+H66PxJ VK/MMh/uwxN9cf75yMGJr0z7TK0WOAAHrHKE1S02DiWPphzhyH++iDXMv5jxSBYcuSqz NcbSO/62A0II4eX+bIR4dtybIYheXr1c7Ds5Lhb5fekKrZ7b+wwwGjwgbRIvlTWXukh/ SctA== 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=ZFz3kTWY/+wXUs1OLC6uD9cOl9ptdl0DUoASkUmwMVk=; b=LpnQ88a108JAjb19CThGACBYW7HihjudeUpGcZoGx8+ecjaU5ocLUg1gmsf1+6yH4H /ZWsQMklg+DBEy8ZBmofohdC2i7+Syvv61WPRZQB5/vbjGo990VdDX1W5psVyvgxvaMD ZjVlZsv5nC2hTWSU5PWPFBU6S8nGpJdIk7R4yreS6t/SlQTncXn3c31OFGBSVmyQGv5j PWVJjlpb9YVEauHp8lWDiINgvtNAqVnafrMpkP3dw+aTaQIfMFFwhBpo7a9spuQGb0yF m6mjDhwu7RwSwoCtDsnbBQHtRBhuc+gZ6ZaCUSjxsKakZXtcxu5CjV+noVoAoEusfA4A FN7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yoLquEjN; 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 v14si3532743oto.127.2019.12.19.10.40.19; Thu, 19 Dec 2019 10:40:31 -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=yoLquEjN; 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 S1727938AbfLSSiA (ORCPT + 99 others); Thu, 19 Dec 2019 13:38:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:55836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727931AbfLSSh7 (ORCPT ); Thu, 19 Dec 2019 13:37:59 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 2C0DE222C2; Thu, 19 Dec 2019 18:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576780678; bh=XOTApJkCiuammR73DmCm1PlS4Vhi+iv3evwzFFAsCI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yoLquEjN1vtiO1A6kYIeqfRRxIwJqd7WkN8QbDXBMkvpO0BRYt+gpOmOntjlzjRgU nfCLQh+RV+venuu+T1Rstj6aUwTuCyv6kEmC/bhNPozOYvH1S89zoajTsg+NdVKsI9 Rm1WJEjxswjRUWDRcQYpXIslRYJCRATXoNakFpew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Sasha Levin Subject: [PATCH 4.4 034/162] altera-stapl: check for a null key before strcasecmping it Date: Thu, 19 Dec 2019 19:32:22 +0100 Message-Id: <20191219183209.838535759@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183150.477687052@linuxfoundation.org> References: <20191219183150.477687052@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Colin Ian King [ Upstream commit 9ccb645683ef46e3c52c12c088a368baa58447d4 ] Currently the null check on key is occurring after the strcasecmp on the key, hence there is a potential null pointer dereference on key. Fix this by checking if key is null first. Also replace the == 0 check on strcasecmp with just the ! operator. Detected by CoverityScan, CID#1248787 ("Dereference before null check") Fixes: fa766c9be58b ("[media] Altera FPGA firmware download module") Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/altera-stapl/altera.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c index f53e217e963f5..494e263daa748 100644 --- a/drivers/misc/altera-stapl/altera.c +++ b/drivers/misc/altera-stapl/altera.c @@ -2176,8 +2176,7 @@ static int altera_get_note(u8 *p, s32 program_size, key_ptr = &p[note_strings + get_unaligned_be32( &p[note_table + (8 * i)])]; - if ((strncasecmp(key, key_ptr, strlen(key_ptr)) == 0) && - (key != NULL)) { + if (key && !strncasecmp(key, key_ptr, strlen(key_ptr))) { status = 0; value_ptr = &p[note_strings + -- 2.20.1