Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4895993ybl; Mon, 9 Dec 2019 19:16:35 -0800 (PST) X-Google-Smtp-Source: APXvYqy4SnAy1kwT03iAddYJx0FQc4F3I02BjnmiI+0DTYBlgaRfYO1lfyM/YEWxOnmhLPq44g9L X-Received: by 2002:aca:4ad8:: with SMTP id x207mr2198708oia.148.1575947795750; Mon, 09 Dec 2019 19:16:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575947795; cv=none; d=google.com; s=arc-20160816; b=Q+fWdW8AfYyusxWyu4ahFYOr2zp3JP+iJdZEgoAqh12wxS4TbbnYKhnfLAcmbHya7m 041pZlSSfMkS5khos5uA9HeqKSVBpgciWnM78tWNO6BeyCpU7ZSq2+3XCuo+FGU5+/qg EBkI8N4UAXVmOw0iIcRor7PeNHjd9Fwpr3bH2a8WPCOvXQvcyUvLW8WvqT4y/a1PcSfE iFaxj3OJUN89qMrxXkIiBis38iTxURmQuOqiYDdQUhqTcLxz5sQxkQ/+3a7KrLcqBQy1 JlaqpJWtRqiWY1kPY+7IV+W/TqUwy7Wn+oZPtF8WHgWoyDI8B/GjSkLBM+K6Bfj+YsGm TkNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=Lf7Lv6WHD6eyJBTAis1s6gLEc0xY5Sw43153FEhgxHY=; b=jRM6z11FuKx3Dyr9mXYqqZ5MWq+yYZINOsh1iNwOf574Ap2+CfRBoVPQY5bhz9+k1p ehv0VNobJddW7W3bb7jUt+6T12wYq+b9D5LgftN2aMDT3oQRzUV8H6wIwmeLdrdtVYx7 iQ3C1jF2NP4jpR6K/vxIXdnfBb1qM9bF/6+c/jCevLJ5ALDbc7eK0wOM0Amc4EODZoSh +JXRhd9w1HkjzxrvhqzsMdnKTlktDNRtf1RENyrbAVoxXcABVoq3IlwgyB0ARdMPgE+P +gra+9K3YJw/J8Dsz4RKJN4RLxsupPZuSa+cHcJdhJIVuCGs0rUFebnevCDtPmq4Ajk3 Y+1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UlD66aZI; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d199si1170373oib.226.2019.12.09.19.16.23; Mon, 09 Dec 2019 19:16:35 -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=fail header.i=@gmail.com header.s=20161025 header.b=UlD66aZI; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbfLJDPp (ORCPT + 99 others); Mon, 9 Dec 2019 22:15:45 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34109 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbfLJDPp (ORCPT ); Mon, 9 Dec 2019 22:15:45 -0500 Received: by mail-pl1-f194.google.com with SMTP id x17so1411053pln.1; Mon, 09 Dec 2019 19:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lf7Lv6WHD6eyJBTAis1s6gLEc0xY5Sw43153FEhgxHY=; b=UlD66aZIOc19ZMVj8QYV3fX/ai5uFQ8LKhkdKHZXDBcoLNMKGficgmJVcQJ+ltNkkT G74hEQFVbnD9CtFpMJ01wDVtH1diWO2KVLfTPZo3KDG/DPoov/AEwX1GlR7XAsUfdMmh 8C/jq9+2T8P1AYVlWyBsia739jJWAsP3MhJRcvmifa85lN8Ke1RWg1AWyJi/kaBfdPif 7CXNW0Xii82zXcxeoIxcqI8Z2G66ATSr4nmQNvDWf5Gb2j3dfyvrPmbAtS9g7zApBFRq V6dDhc42VgAKAoTPosgBRdbFWzYTKttjOTUjWvg368hg7UVsVj624kKrpGpEFeBhSd38 /Mlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lf7Lv6WHD6eyJBTAis1s6gLEc0xY5Sw43153FEhgxHY=; b=OiQ2QeD+s80710X8XH7YnjGf42XLRCvqbXs3WpcqwAe0Itbh4AcNFi1WvAJEZlF0ay o9+amPYIHmbdzeRuJ8yaLj0kmcLBw5H8o9Qt6lJ2e+3j6MbpXxkyPGooLhZzud8vEkW6 vXz5gACa5+Edkhk7lVV41CBzwixnVpQzIRno/t7xHbFZmmShVHkOCNAbcRRRv6dcwcum SGGBoqBUMgpmFwJcFa2sUzeoV831Bz2efzYtWBCiv2cp5/vFnsNx5QI2tNYfNA5zlBu0 Md+CUIF3mTjmLY7SHk0TTjzV0+2W6GsHe4M94GssrT3YBCIf2MCHx5zxX8hEKcRLlig5 hWUA== X-Gm-Message-State: APjAAAUcmU5Q9W5+YAabpvUg7kPdFGpw4C0qPZtHkM+sohtTbyKfq272 BMFwCFNwpTN43BYIh3FQscZkzyOeeg4= X-Received: by 2002:a17:902:7c0a:: with SMTP id x10mr33699831pll.168.1575947744695; Mon, 09 Dec 2019 19:15:44 -0800 (PST) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.gmail.com with ESMTPSA id i127sm942717pfe.54.2019.12.09.19.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 19:15:43 -0800 (PST) From: Chuhong Yuan Cc: Michael Tretter , Pengutronix Kernel Team , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v2] media: allegro: add the missed check for v4l2_m2m_ctx_init Date: Tue, 10 Dec 2019 11:15:32 +0800 Message-Id: <20191210031532.18603-1-hslester96@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org allegro_open() misses a check for v4l2_m2m_ctx_init(). Add a check and error handling code to fix it. Fixes: f20387dfd065 ("media: allegro: add Allegro DVT video IP core driver") Signed-off-by: Chuhong Yuan --- Changes in v2: - Fix the use-after-free in v1. drivers/staging/media/allegro-dvt/allegro-core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c b/drivers/staging/media/allegro-dvt/allegro-core.c index 6f0cd0784786..66736beb67af 100644 --- a/drivers/staging/media/allegro-dvt/allegro-core.c +++ b/drivers/staging/media/allegro-dvt/allegro-core.c @@ -2270,6 +2270,7 @@ static int allegro_open(struct file *file) struct allegro_channel *channel = NULL; struct v4l2_ctrl_handler *handler; u64 mask; + int ret; channel = kzalloc(sizeof(*channel), GFP_KERNEL); if (!channel) @@ -2341,6 +2342,14 @@ static int allegro_open(struct file *file) channel->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, channel, allegro_queue_init); + if (IS_ERR(channel->fh.m2m_ctx)) { + ret = PTR_ERR(channel->fh.m2m_ctx); + v4l2_fh_del(&channel->fh); + v4l2_fh_exit(&channel->fh); + kfree(channel); + return ret; + } + return 0; } -- 2.24.0