Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp118108rwb; Tue, 27 Sep 2022 23:41:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Lmf0z83cukvvh/sNCeOW2tE+ng4ro/eJaC9SfUuf3mNpC5psnvMDV1Df5ZrN6lkDOIMuB X-Received: by 2002:a17:907:6da3:b0:783:5665:18dc with SMTP id sb35-20020a1709076da300b00783566518dcmr13617067ejc.173.1664347291792; Tue, 27 Sep 2022 23:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664347291; cv=none; d=google.com; s=arc-20160816; b=yTmWkdulNisQUf2H8QsCkw8H/LKBjJuQqbd9+GpauJJYdBese5otuSzfhHBp4RxkOX u7B9CzsiKB/bVeaxjBq325hfLEWd/48jUeuzePSnNRKkdd1ITAKr/fdrwC3RXt8oC24y JECdmNa3zf+TND1D1CmGwVTmPdCkwlF/0lBpycyCmYruUx0+PDDzTIPMbDDX4eEGaP6M ICAYJTAEbkd8IslPNiempxlKhH6CTO8Zdka0ctvnXWL35LOzk8S5qObA9JVco5bvnE0S vxwEV7A6lcVgbV94ARq7A2m4CKnbFGbxPwvNWZaylxL7BhnKiuCWHV4qK4q0UmMN1nVV ptmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=PRqQyGoq9wOWzgyinUTHIHWFfyBK2VGJdHeSaidSayw=; b=L/TZ9rW1ijb5l5y1i1OhwaYp6q2Uv410fQyHukK3wW2QViLHWpEzOYQq20f0fSbkBE SPTm5OTb2y9Q05s+wDuxVUuuxCRWjQB07atWWrLQMh31CrLp8dPXy2LAEW/qZ3eYOiXY jHfiLm+g7ITmVAhecKCIhv4fP/t5TdkUZXhuI/mxslRUGXwz3k09gae63Mvq61Xyq45O qkFm7MAfS03gJIO/XB30b5sjsMsVhfqraP1XNAHidRuM1Pr535dKqCshEKMkpi8kXkLl ZjBWbk1p/e6U1Q/kt+BbdfqjI0hYMp94iWMZG2PwAhW6oc8kGmcInAvsj4fGnOIzL3BF B3tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=SQtzEpeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd13-20020a056402206d00b004533149e228si3501081edb.618.2022.09.27.23.41.06; Tue, 27 Sep 2022 23:41:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=SQtzEpeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232719AbiI1GYw (ORCPT + 99 others); Wed, 28 Sep 2022 02:24:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232892AbiI1GYt (ORCPT ); Wed, 28 Sep 2022 02:24:49 -0400 Received: from mail-m973.mail.163.com (mail-m973.mail.163.com [123.126.97.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 17B234331C; Tue, 27 Sep 2022 23:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=PRqQy Goq9wOWzgyinUTHIHWFfyBK2VGJdHeSaidSayw=; b=SQtzEpegast2VoLmoC6v9 9AEvPVntyyr+cyLnxxT8nOeoRWsUbqk0nTZatEgwv83GL9klT1OtUyirragTHymZ 7ljUr7qRuAmM2ZWK+8540BytbCIy4pYhpG5PXqmO5HoX9D7c6ZybPBseg9B4CM99 G6L4ZSyGXWPBFXT1wgF5M4= Received: from localhost.localdomain (unknown [36.112.3.106]) by smtp3 (Coremail) with SMTP id G9xpCgBHz4BH6DNjsnURhA--.18298S4; Wed, 28 Sep 2022 14:23:10 +0800 (CST) From: Jianglei Nie To: gregkh@linuxfoundation.org, tzimmermann@suse.de, andriy.shevchenko@linux.intel.com, javierm@redhat.com, sam@ravnborg.org, steve@sk2.org, noralf@tronnes.org, u.kleine-koenig@pengutronix.de Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] staging: fbtft: core: fix potential memory leak in fbtft_probe_common() Date: Wed, 28 Sep 2022 14:23:01 +0800 Message-Id: <20220928062301.6399-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: G9xpCgBHz4BH6DNjsnURhA--.18298S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrury8Ww1UtFW3WrWrXF15twb_yoWfCrXEvw 1jvryxJrW8Cwn2kw48KFW5XFWSvr1fZr4rJFyUtas8Xay5ur15J3ykXwsxKa1Ut3yjq34S kr4rJr4jgw15WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKpnQ7UUUUU== X-Originating-IP: [36.112.3.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiPg6KjFxBuOAwbgAAst X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fbtft_probe_common() allocates a memory chunk for "info" with fbtft_framebuffer_alloc(). When "display->buswidth == 0" is true, the function returns without releasing the "info", which will lead to a memory leak. Fix it by calling fbtft_framebuffer_release() when "display->buswidth == 0" is true. Signed-off-by: Jianglei Nie --- drivers/staging/fbtft/fbtft-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index afaba94d1d1c..ecf595aff786 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -1225,6 +1225,7 @@ int fbtft_probe_common(struct fbtft_display *display, if (display->buswidth == 0) { dev_err(dev, "buswidth is not set\n"); + fbtft_framebuffer_release(info); return -EINVAL; } -- 2.25.1