From patchwork Thu Jan 16 03:31:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 23245 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 093C920555 for ; Thu, 16 Jan 2014 03:36:02 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id q3sf3594650gge.4 for ; Wed, 15 Jan 2014 19:36:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=UoacltAhHCz+baAQM7fe4GAGZyRvtVdmYvBNpldj74w=; b=DcEdkv37mmqL8hDbcSSn8MeQixMabOwco/lFyw4rvUe50K2a86zipVi+OafzLW9fOZ ed9YcgzDlq+h13h/qm+MVaNPwomsNQr9QPYdI52OU5EPDlWYxT8alL1C08UpzcQpv7il 2tEI/j0BujwAJzziE3qOkAIjnqIoTnPPtT2FhxSrQh2LkZuM5g1VpIBCRig4Xf6vLzgs i2bc+gtbgSDYmD6J+PqMVmS3Pvhf42pNvIdbMbMx5sz+AwmgVFz4jAwwee2xKbsDIKzv mDQjARPcrPK8tkAMXuD0Cuegoy5zjPP3WQRpIFz7P07x45gch7yVtn1RuQxF2xLwEn/D fZow== X-Gm-Message-State: ALoCoQnYvcWLwBA6EHG1itwzisjvmr1T6eb3GVJanRR8sMLpqihwmJ2rBOeoEcCNah/ASHfOZPQc X-Received: by 10.58.221.98 with SMTP id qd2mr2298719vec.5.1389843361983; Wed, 15 Jan 2014 19:36:01 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.108.227 with SMTP id hn3ls759266qeb.74.gmail; Wed, 15 Jan 2014 19:36:01 -0800 (PST) X-Received: by 10.52.26.148 with SMTP id l20mr269690vdg.28.1389843361919; Wed, 15 Jan 2014 19:36:01 -0800 (PST) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id b20si2595805veu.98.2014.01.15.19.36.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 19:36:01 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id x14so748259vbb.36 for ; Wed, 15 Jan 2014 19:36:01 -0800 (PST) X-Received: by 10.52.244.49 with SMTP id xd17mr270724vdc.26.1389843361719; Wed, 15 Jan 2014 19:36:01 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp318406ved; Wed, 15 Jan 2014 19:36:01 -0800 (PST) X-Received: by 10.68.111.98 with SMTP id ih2mr6965424pbb.73.1389843360752; Wed, 15 Jan 2014 19:36:00 -0800 (PST) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by mx.google.com with ESMTPS id n8si5614978pax.218.2014.01.15.19.36.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 19:36:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.44 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.44; Received: by mail-pa0-f44.google.com with SMTP id kq14so2084383pab.3 for ; Wed, 15 Jan 2014 19:36:00 -0800 (PST) X-Received: by 10.68.12.138 with SMTP id y10mr7023318pbb.101.1389843360139; Wed, 15 Jan 2014 19:36:00 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id vn10sm11459578pbc.21.2014.01.15.19.35.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 19:35:59 -0800 (PST) From: Sachin Kamat To: dri-devel@lists.freedesktop.org Cc: inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 1/1] drm/exynos: Fix freeing issues in exynos_drm_drv.c Date: Thu, 16 Jan 2014 09:01:45 +0530 Message-Id: <1389843105-20741-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Make 'file_priv' NULL upon freeing and add a check before dereferencing to avoid the following errors: drivers/gpu/drm/exynos/exynos_drm_drv.c:182 exynos_drm_open() error: double free of 'file_priv' drivers/gpu/drm/exynos/exynos_drm_drv.c:188 exynos_drm_open() error: dereferencing freed memory 'file_priv' Signed-off-by: Sachin Kamat --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 9d096a0..ee84a7b6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -173,6 +173,7 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) ret = exynos_drm_subdrv_open(dev, file); if (ret) { kfree(file_priv); + file_priv = NULL; file->driver_priv = NULL; } @@ -184,7 +185,8 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) } anon_filp->f_mode = FMODE_READ | FMODE_WRITE; - file_priv->anon_filp = anon_filp; + if (file_priv) + file_priv->anon_filp = anon_filp; return ret; }