Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3796709ybi; Mon, 29 Jul 2019 12:48:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjuoGOf/B80ZLkOUPX/XW0wbilAiP/mdBr2KwRSQDNadlfR1L0ilIia3EAdwmbp7uXqNFw X-Received: by 2002:a17:90a:b00b:: with SMTP id x11mr114194126pjq.120.1564429711945; Mon, 29 Jul 2019 12:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429711; cv=none; d=google.com; s=arc-20160816; b=P7LBL64GDYTWYfepHULCic8WdEE8SXXHlS6sCXrf0nuUmHv5fkQ9eRBQ9QoQNEjRqg kCmsn5A0t//3x8Kywz87MGlbNZBpji+FE35qCVPbGuQZazA/ABsvLndCgs4n3fQXnkLY 7YWP7YTduKo4PyPfy5FbRLQcohQlH5zKA+GpVZZesoa2KeW6ZMNHZndibPKmxpjpzIuF 6+iI5hmeVC0/RtpCWv4i6uG8UNFQAzj/bj/RuNhdesd8YS2O7RLvp1R+03MxKQA7QlVa hTq4MbjbXdY3wFULVA4TM+KuvMV/wbA+Jwg+y/lXGRm9JnsLzHSQvniHKpafYnGeCRi/ U5qw== 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=VsnJ5JMaEHDb7jXYDKhtOPhpZjXYyJk5OTzBkis2Ht4=; b=cEvOL64HrhYlDtRyJb/KKCcHxYG2UvukjeVBQGA8jlF78V/Qll3DxX2SZS0HCsBT5W TDmYbIr7jnw4Db28ujtobLNPyQ8cqrnuHEBiAD9ART8mrktMb5gd+rfbHG5g3neFsX7y KXefjot/y4OfRTAoKWC/QwYvKwG0Tdzp3g8QgIzdWENa2v5zYLd8b0ov4n9teQLcsOWQ T2EaY7Tga7m4aW9bei4H6rVHnRLvugy5lDh5/H15jAXNaLeNGHv3V94oY3jYTgy0tkSX AgOsbz19jQo1M9BN84rxnLLHC69qH+hdmjgAcPtRBbgP1qU1S0POkno0HB1/+15dvMOE bm8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ibfHCSJC; 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 g11si28453179pfi.282.2019.07.29.12.48.17; Mon, 29 Jul 2019 12:48:31 -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=ibfHCSJC; 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 S2390247AbfG2Tqx (ORCPT + 99 others); Mon, 29 Jul 2019 15:46:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:36288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389700AbfG2Tqv (ORCPT ); Mon, 29 Jul 2019 15:46:51 -0400 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 CBCFE21655; Mon, 29 Jul 2019 19:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429610; bh=VXt4mxRZygTiPKRvtfmFm5ZTuq8VmnsWphZV2ka10o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ibfHCSJCkUNSFUI9yo460Cv9yfO4fewJ3AD9a6T/XOXP6tVmmaklyFQ/5piSTXORc XlLJB1K/2SHpMi0vjDbkE7eA/wP8cXH593MUiMnyHui5SWxsVw5fzeD9mkCB6DExS8 1nCsgBUmSbgeVYDwaRSGZYujBtUjyP3pvPyY5j/A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gen Zhang , Jani Nikula , Sasha Levin Subject: [PATCH 5.2 031/215] drm/edid: Fix a missing-check bug in drm_load_edid_firmware() Date: Mon, 29 Jul 2019 21:20:27 +0200 Message-Id: <20190729190745.556351742@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 [ Upstream commit 9f1f1a2dab38d4ce87a13565cf4dc1b73bef3a5f ] In drm_load_edid_firmware(), fwstr is allocated by kstrdup(). And fwstr is dereferenced in the following codes. However, memory allocation functions such as kstrdup() may fail and returns NULL. Dereferencing this null pointer may cause the kernel go wrong. Thus we should check this kstrdup() operation. Further, if kstrdup() returns NULL, we should return ERR_PTR(-ENOMEM) to the caller site. Signed-off-by: Gen Zhang Reviewed-by: Jani Nikula Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20190524023222.GA5302@zhanggen-UX430UQ Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_edid_load.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c index 1e5593575d23..6192b7b20d84 100644 --- a/drivers/gpu/drm/drm_edid_load.c +++ b/drivers/gpu/drm/drm_edid_load.c @@ -278,6 +278,8 @@ struct edid *drm_load_edid_firmware(struct drm_connector *connector) * the last one found one as a fallback. */ fwstr = kstrdup(edid_firmware, GFP_KERNEL); + if (!fwstr) + return ERR_PTR(-ENOMEM); edidstr = fwstr; while ((edidname = strsep(&edidstr, ","))) { -- 2.20.1