From patchwork Wed May 31 07:28:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13261602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48634C77B7C for ; Wed, 31 May 2023 07:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Wm9NwYH0j7tE1JZPMzfc1qGuaUqpdqxowwDDEFhqHqg=; b=fkQovm+Vvvzttv pkT0t6ZJLDgUQaRfwVbYRmyzC28DS9/peDpXLZss3lgYcBpPP6rL8Xxrh5F+CI8VjFj+z+r+2LZom PHfZkycjlVT+/Jiw0z57SL8SaeZBnD9SWDB8YK8Hevp9egoy17JRKwmblc9QRHN4XNlQGNgpmJFQ+ ZDwMOS0Ni7X4hCznRmxBEuZetHvWrmRXingQjTrsV2lk24ahtrjO9N8TaIaltQGb1EpqFNA0Vbstb u3w5Wl2Wi3+lBk7A3RO/GzS6b+X/RN1+w04tZKafV9ETJObzWoqmcltWv3jC0DgN2MDom1vnku3IL k5r4ZtjRysjTZb9lz6AQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4GGr-00GRYE-1P; Wed, 31 May 2023 07:29:25 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4GGn-00GRWM-1W for linux-arm-kernel@lists.infradead.org; Wed, 31 May 2023 07:29:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685518161; x=1717054161; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=OFS01oMh3vyVox4i27eCh4n3gvVM54Ok/qp21x0hPuA=; b=KsDubhIfr0fvVrcCafqL+rJq762XIDpiu9hde0D5f/uUHTiftAcTSq0L wAbEKTD+p5FbnOFOtoStmwgmudd+s4mSXWwaczJN2pcrdUB/luawgplxC JZ4eE/2xHvF+rWVOmNtZqZQhFFBc2MvUD3zOybZBGx8BgnLG8gBrf1V53 KWKxucT/6XFD/iUxcch1Z0emDGzFVjaHsQPTk8g5gb0eHjnjL0WWQt8DI EYkjSvpCX0i1AelyC3a58sAOI2uk3d+YzqARK3eLMRUTAg+U2srHRYDxH C9CfDFtqKCeRh4vRun8JQkTps4gWY0IYPAHY00oRzsQaF44n0PJIAUCIq A==; X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="227735487" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 31 May 2023 00:29:16 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 31 May 2023 00:29:16 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Wed, 31 May 2023 00:29:10 -0700 From: Claudiu Beznea To: , , , , , , CC: , , , , Claudiu Beznea Subject: [PATCH] drm/stm: ltdc: check memory returned by devm_kzalloc() Date: Wed, 31 May 2023 10:28:54 +0300 Message-ID: <20230531072854.142629-1-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_002921_699712_0275BEAF X-CRM114-Status: UNSURE ( 9.91 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org devm_kzalloc() can fail and return NULL pointer. Check its return status. Identified with Coccinelle (kmerr.cocci script). Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats") Signed-off-by: Claudiu Beznea Acked-by: Raphael Gallais-Pou --- Hi, This has been addressed using kmerr.cocci script proposed for update at [1]. Thank you, Claudiu Beznea [1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/ drivers/gpu/drm/stm/ltdc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index 03c6becda795..9f3ac54d4cb3 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -1579,6 +1579,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev, ARRAY_SIZE(ltdc_drm_fmt_ycbcr_sp) + ARRAY_SIZE(ltdc_drm_fmt_ycbcr_fp)) * sizeof(*formats), GFP_KERNEL); + if (!formats) + return NULL; for (i = 0; i < ldev->caps.pix_fmt_nb; i++) { drm_fmt = ldev->caps.pix_fmt_drm[i];