Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp718393pxb; Wed, 27 Oct 2021 11:00:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6lQ15eBzpGLtrlKwwToOdoxW/ug8IU3GH0Uk2ySKEiKp+Od4RZuztD1ehEvUJitDg7+kx X-Received: by 2002:a50:c30a:: with SMTP id a10mr41202972edb.206.1635357646189; Wed, 27 Oct 2021 11:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635357646; cv=none; d=google.com; s=arc-20160816; b=QN2KKdkB7Rx9W/WpRg8lZuTQbxUPF4Zxz+tTBwLHhhUgceHKQ4wbi2Ag5ZHADZuK/P sdoo14r+X+EXRx1GMp7mT5XI1YZpuZwYS3sc5198FPfeVKTctsOXCdV3FaCiEqgpHLMc u0QwO3F81bOqYkxpirKX+4LoAH2lCFp5u3oWz8Zh4BCsscR5FFuJD3EZ+dswC2C7kQGz sG3ig1zxA+aGS/9yi0bK0pGrJV73NnLHDEopQmaQv17y74Fy8j1l/Wn8gEQHALgUyC3Z ptN2GjIIEiIMjBr2ZNnaOqyxw3t4OZILcEuBqQyEpXEGjQ8NVL5wcqPWLl1xpmypSNDh DTLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=gwwKZSkClD6ZbncJNtCYx9HarUAhL5A9fzaLxzfmhZE=; b=RuEEFjnPF0NmFRxu8rykkrRvjafgIYmBKYnwsF05Dw3tE/Hl7T6op09kCndK+suILn QfIljxODxDs/flRQPwog0IgzXssKWctVUGAMxzK/nApx6S1p06CPLg09ckDdgvL8u4p2 cHUHB5JosrjPGbAN1CZ4n4bsT88jJl3+UidXkefbXf6A6F5N919zzZqZPJNw5Q4iW+pG MD5frN93IA0KS12NjGoiFbk+Qr6tOeMQV5J8n6z1YuFIoA8+/ShX9aFNgJX/P4MEqser NORjqyI6zteFQRg8eAw8WBpzjJmcgCVLh6dMECMCwLUFjmaXfZL+o6K1kI5q8geKtC23 XO8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ix5DU9CU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd9si689624ejc.757.2021.10.27.10.59.57; Wed, 27 Oct 2021 11:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ix5DU9CU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236771AbhJ0GDQ (ORCPT + 99 others); Wed, 27 Oct 2021 02:03:16 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:53002 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbhJ0GDP (ORCPT ); Wed, 27 Oct 2021 02:03:15 -0400 X-Greylist: delayed 454 seconds by postgrey-1.27 at vger.kernel.org; Wed, 27 Oct 2021 02:03:15 EDT Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 19R5suWQ115299; Wed, 27 Oct 2021 00:54:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1635314096; bh=gwwKZSkClD6ZbncJNtCYx9HarUAhL5A9fzaLxzfmhZE=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=ix5DU9CU3JIpQvYHXbR0+jo2mPJjUKvDWC+zGIKXBvUBRuFWVBxnvQDerrFkYR1tM 8akkabRWpJbYvtTHtcXHNeqCgiqy+0bhSfFRZ2rim9vLZByj8htuKdYkNDgw9OTMrU E9a/MUzqQjK5/omgLe6BGgftiYgYclfpUCDraibs= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 19R5suPA001249 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 27 Oct 2021 00:54:56 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 27 Oct 2021 00:54:55 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Wed, 27 Oct 2021 00:54:55 -0500 Received: from [10.250.234.118] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 19R5sqJ1107019; Wed, 27 Oct 2021 00:54:53 -0500 Subject: Re: [PATCH 1/2] dmaengine: ti: k3-udma: Fix NULL pointer dereference error for BCDMA To: Peter Ujfalusi , Vinod Koul CC: , , Vignesh Raghavendra References: <20211027055254.10912-1-kishon@ti.com> From: Kishon Vijay Abraham I Message-ID: Date: Wed, 27 Oct 2021 11:24:52 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20211027055254.10912-1-kishon@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi All, On 27/10/21 11:22 am, Kishon Vijay Abraham I wrote: > bcdma_get_*() checks if bchan is already allocated by checking if it > has a NON NULL value. For the error cases, bchan will have error value > and bcdma_get_*() considers this as already allocated (PASS) since the > error values are NON NULL. This results in NULL pointer dereference > error while de-referencing bchan. > > Reset the value of bchan to NULL if the allocation actually fails. > > Signed-off-by: Kishon Vijay Abraham I Please ignore this series. There was some stray patches left which I failed to notice before sending. I'll resend a clean one. Thanks, Kishon > --- > drivers/dma/ti/k3-udma.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c > index a35858610780..14ae28830871 100644 > --- a/drivers/dma/ti/k3-udma.c > +++ b/drivers/dma/ti/k3-udma.c > @@ -1348,6 +1348,7 @@ static int bcdma_get_bchan(struct udma_chan *uc) > { > struct udma_dev *ud = uc->ud; > enum udma_tp_level tpl; > + int ret; > > if (uc->bchan) { > dev_dbg(ud->dev, "chan%d: already have bchan%d allocated\n", > @@ -1365,8 +1366,11 @@ static int bcdma_get_bchan(struct udma_chan *uc) > tpl = ud->bchan_tpl.levels - 1; > > uc->bchan = __udma_reserve_bchan(ud, tpl, -1); > - if (IS_ERR(uc->bchan)) > - return PTR_ERR(uc->bchan); > + if (IS_ERR(uc->bchan)) { > + ret = PTR_ERR(uc->bchan); > + uc->bchan = NULL; > + return ret; > + } > > uc->tchan = uc->bchan; > >