Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3817417ybi; Mon, 29 Jul 2019 13:12:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiX5k4fWntDuCWekOc4CMfGAJgZYRIuelFJcG1CP7BOS3UiQJJHOvhKeV5BSn9/jGyi6fC X-Received: by 2002:a62:3103:: with SMTP id x3mr37566230pfx.107.1564431147138; Mon, 29 Jul 2019 13:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431147; cv=none; d=google.com; s=arc-20160816; b=P9UYlu2PTIEAz5yBESGMUMug5CO1a0XKGbbRf+NeRLUp3G18G2QxwWTKXFCyvPJczx 2IWy5QhV6R7vS5O22AvgdXWTwn/+YP4WyOJ1t7qRyJdGifGUD99kUauIp1Y98MaY/QMb pJS1Iy+7UEJ29jPBcT1Rqy1BIWctcIsojpEhcSUykdO3IbdZDq/cO6GvhCmfSwUZ9wW0 Bwv/2gwJodJGV17UXO0zISuD7V5iDH7onYfkeKGWeFTO756A5tNXFyg9QfyfhRUjEwCO xigkmSXCM1qTdcy4a+4NhHSAfEDPm/TvfrWgF28PVSUescrl4DZnyzO/tF8UNSLBClGj Jdxg== 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=b9YTPBJhDiYD97OwIn7y9uyCVVQuyaYSEpWyuV0Luxo=; b=sADVRqKa/8tLWqX46HyxC7gYjH7LDGSNzBkokg4Lx6RiOC/RNuUVh8n6Mw2nOTGoI8 Vm2g6gU/nnIKa28hYTMxRKy1XbmDKkMapz3EPaNut3BABd6AKrv4Or+pT4aZlesTQ0xt HBhf3tuyvb4w97qDAw7GFLBufGixaYdszFyOMm+MSvGMuv9e/PUryekNOyljYRa113Nt DFsiwbm4NfgzqS5/Vh2q5oxsGWRThqhvMRRBwcHs9yw4HCp2ObMbQR7sEoCM7ecf2DhO hMUw2tvrQg0S0iY7gZFXHYlUkJT90cjzEnlDkij8T7SDSi5DEKJKAZ3OrAQfCUbh4kRS nFfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dw8z936X; 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 65si28909650pfg.241.2019.07.29.13.12.12; Mon, 29 Jul 2019 13:12:27 -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=dw8z936X; 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 S2388522AbfG2Tfp (ORCPT + 99 others); Mon, 29 Jul 2019 15:35:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:50012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfG2Tfk (ORCPT ); Mon, 29 Jul 2019 15:35:40 -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 2561C217D4; Mon, 29 Jul 2019 19:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428939; bh=G65mtQ9TaQSShLzvl+hKMv4/rU9GifJgKQgXHhXgXD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dw8z936XlyXTcRO5jTpfZfiBG79gKLA7j8ltcUg9KGx2bTEM1aUd7Zh4RlWE3mmbK Ue3dsEw0CFIhZ2V6zIGcPP59i9G2evmAgNRs9Mhv2YVWdOzEmtf2hXTnbum4SGXCfN hfzTFXxnfAw+vpVCtztL+2elJDHXsbHr3Bzdh/jA= 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 4.14 227/293] drm/edid: Fix a missing-check bug in drm_load_edid_firmware() Date: Mon, 29 Jul 2019 21:21:58 +0200 Message-Id: <20190729190841.890464443@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 1c0495acf341..06656acea420 100644 --- a/drivers/gpu/drm/drm_edid_load.c +++ b/drivers/gpu/drm/drm_edid_load.c @@ -274,6 +274,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