From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BC85C433ED for ; Wed, 19 May 2021 10:21:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE9BE61244 for ; Wed, 19 May 2021 10:21:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE9BE61244 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F5F16E29D; Wed, 19 May 2021 10:21:47 +0000 (UTC) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3753F6E29D for ; Wed, 19 May 2021 10:21:45 +0000 (UTC) Received: by mail-wm1-x332.google.com with SMTP id u133so6977554wmg.1 for ; Wed, 19 May 2021 03:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=agmM9r0ocVor9/dELzPhDyxV/Q6g4/KHl3BaIRPfQMo=; b=Q6r5E6/JTJ/+6maNrSQPa/GSrHfkMCdUNc4pqocJv5EXGNMDrowwxW1txNa/5N/+xk GYwR8lgHZ/BFD65gvsud0SnoBSz3HfCltufKq3dO9clYMX2s9Tcy+dbP2wX4TL8a2nNe n88muJcwXgf0oVKFKyBM87UMvPIeEOJKEJsJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=agmM9r0ocVor9/dELzPhDyxV/Q6g4/KHl3BaIRPfQMo=; b=bRFPQdJ4UOWt/NTFD4rMnmbIllOCfjtCfL9v/OCLkajwx5+UIcNjQI0qdw+RTD6+DL RIq7YGDyc7DYebeKOt4mxLEjRCbWkbEg2FVebmDBwgCoAF4hMHLnIw/n6zsuI6/h2Bfs J5bC7UL/Yyiz0xsNCeCVsfDosIJMbJBYLFaDO01w4jf2ypHuw8zSDwQ5rDplL8z482RO 2JmTJ1+F2flaxYtVK9o98hBYN+GG8K3LdRAze84bKIuIa+nLiGqkaXEzJ7SLRBlmFnca tg7bTzs+rVC6x3Br3ixQKPkYiwXSImN3uIIp1riQ8mpmRM9GsYVrW7q9bXXeevYtcOqn cinA== X-Gm-Message-State: AOAM533yiAtlnnsw6GU08zl2bNaGXrdGaXF4dgamo8I/sVm1g5T/XTmh gsyeVoNQtde6fy7kzhgj6nAmrsVimC1wCA== X-Google-Smtp-Source: ABdhPJyrrNplyPF4l7h+AsOBRZFblqke572pHjkUgJUA7dvxQHAp9nrQ62XQOtKxwOeNoU38M3wWtw== X-Received: by 2002:a7b:cc19:: with SMTP id f25mr10714124wmh.153.1621419703930; Wed, 19 May 2021 03:21:43 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id q13sm23556881wrw.56.2021.05.19.03.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 03:21:43 -0700 (PDT) Date: Wed, 19 May 2021 12:21:41 +0200 From: Daniel Vetter To: Zou Wei Subject: Re: [PATCH -next] drm: Fix missing unlock and free on error in drm_legacy_addbufs_pci() Message-ID: Mail-Followup-To: Zou Wei , maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, joseph.kogut@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <1621341302-112089-1-git-send-email-zou_wei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1621341302-112089-1-git-send-email-zou_wei@huawei.com> X-Operating-System: Linux phenom 5.10.32scarlett+ X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: joseph.kogut@gmail.com, tzimmermann@suse.de, airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, May 18, 2021 at 08:35:02PM +0800, Zou Wei wrote: > Add the missing unlock and free before return from function > drm_legacy_addbufs_pci() in the error handling case. > > Fixes: 70556e24e18e ("drm: remove usage of drm_pci_alloc/free") > Reported-by: Hulk Robot > Signed-off-by: Zou Wei Applied to drm-misc-next, thanks for your patch. -Daniel > --- > drivers/gpu/drm/drm_bufs.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c > index 4805726..c23d7f7 100644 > --- a/drivers/gpu/drm/drm_bufs.c > +++ b/drivers/gpu/drm/drm_bufs.c > @@ -984,8 +984,16 @@ int drm_legacy_addbufs_pci(struct drm_device *dev, > > while (entry->buf_count < count) { > dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL); > - if (!dmah) > + if (!dmah) { > + /* Set count correctly so we free the proper amount. */ > + entry->buf_count = count; > + entry->seg_count = count; > + drm_cleanup_buf_error(dev, entry); > + kfree(temp_pagelist); > + mutex_unlock(&dev->struct_mutex); > + atomic_dec(&dev->buf_alloc); > return -ENOMEM; > + } > > dmah->size = total; > dmah->vaddr = dma_alloc_coherent(dev->dev, > -- > 2.6.2 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch