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 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB85CFA373E for ; Fri, 21 Oct 2022 16:38:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E5D8385030; Fri, 21 Oct 2022 18:38:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ETPgZsC5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E7AB885032; Fri, 21 Oct 2022 18:38:38 +0200 (CEST) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8511284CDF for ; Fri, 21 Oct 2022 18:38:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x52e.google.com with SMTP id u21so7968643edi.9 for ; Fri, 21 Oct 2022 09:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=L4sh62V0tkNW1Rdd9//DJNiomHIrIkQi09UaPrszN10=; b=ETPgZsC5hbQkjYF4Dcv5amHRE/sRU0rNc4CLR2rCt12OKD8Tk+aWSZAg7a1gBIm92+ iisN42zL0XdHm4rHvDapvkoHlu+czvt0T5E7UK2vydKQs7tXePkR1bHcR857DWrnv9ZN agR/Zh/BiMmVQjCCwB3gd6VXtF0ZTuOJ/4NJwMl3xGYF4A+Wkl38j+gedQSUxXHtU+Td 0LXelf/xkSb/gMIFkuFdWdry6sLAZDSszHehQW57myC0Bj70X8MaR3Zrl28sL4jkqPdx pbJbarZCWDWUzyPK9GIcy6yUOKfPMsaMg0TiEmBwj9SDUDEFPOTH+wWeNWG1nO0E/Azd aglQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=L4sh62V0tkNW1Rdd9//DJNiomHIrIkQi09UaPrszN10=; b=X4WjmfFUDQxE9Kjuf1Hbe1zJuqKoYZaOEIkJw9Y2Aah2odGY6LHWIxTQqMjBpS3qXr 6CbbBIphQq+62ixsw8Dbs5n6+uBIT54ocMVoPVo6nvV1CTYvPmsj07fBHWC2tHg2eVEo rIoDU9uCH1pS/SLl99JiWD6ZM57ZGHMPErQughwPao3sOtgdbD8EPpg6V2Knmi+rwu6I T/JLVNXgz5/uUxHVPu7dMJaoTjyZJWPniBULI7faTsI1V7bwhcCSKDLjl0oi4wSYPX2n caBiJ8clJ6iHKmn+hkzNWGUmnGCdY+DIDIw1BlLCJcczPGaAlBwXBZvh/PmQA8pu7wLe K8kQ== X-Gm-Message-State: ACrzQf2PvnnlLwDOpYqyX6CwtwY117/IJYaPoxUGqPBeBct2LitqjL9B vLYWyC2D/XZUlefwiptZWWQjog== X-Google-Smtp-Source: AMsMyM43+D7h/eBvdyWbtnXti52ySYFZN94Qxz7YYDwlVgdrZPX+6ih3IE+vCB3OeUvHGxy6nQw7TA== X-Received: by 2002:aa7:c78e:0:b0:456:c524:90ec with SMTP id n14-20020aa7c78e000000b00456c52490ecmr18204260eds.192.1666370316144; Fri, 21 Oct 2022 09:38:36 -0700 (PDT) Received: from hera (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id l17-20020a1709063d3100b00780636a85fasm11802532ejf.221.2022.10.21.09.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 09:38:35 -0700 (PDT) Date: Fri, 21 Oct 2022 19:38:32 +0300 From: Ilias Apalodimas To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Takahiro Akashi , Patrick Delaunay , Patrice Chotard , Simon Glass , Tom Rini , Etienne Carriere , Jassi Brar Subject: Re: [PATCH v15 03/15] FWU: Add FWU metadata access driver for GPT partitioned block devices Message-ID: References: <20221021124608.681387-1-sughosh.ganu@linaro.org> <20221021124608.681387-4-sughosh.ganu@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Fri, Oct 21, 2022 at 09:57:45PM +0530, Sughosh Ganu wrote: > hi Ilias, > > On Fri, 21 Oct 2022 at 20:33, Ilias Apalodimas > wrote: > > > > Hi Sughosh > > > > > +{ > > > + int ret; > > > + u32 len, blk_start, blkcnt; > > > + struct disk_partition info; > > > + > > > + ALLOC_CACHE_ALIGN_BUFFER_PAD(struct fwu_mdata, mdata_aligned, 1, > > > + desc->blksz); > > > + > > > + if (!mdata) > > > + return -ENOMEM; > > > > ENOMEM is usually for allocation failures this is an -EINVAL > > > > > + > > > + ret = gpt_get_mdata_disk_part(desc, &info, part_num); > > > + if (ret < 0) { > > > + printf("Unable to get the FWU metadata partition\n"); > > > + return -ENOENT; > > > + } > > > + > > > + len = sizeof(*mdata); > > > + blkcnt = BLOCK_CNT(len, desc); > > > + if (blkcnt > info.size) { > > > + log_debug("Block count exceeds FWU metadata partition size\n"); > > > + return -ERANGE; > > > + } > > > + > > > + blk_start = info.start; > > > + if (access == MDATA_READ) { > > > + if (blk_dread(desc, blk_start, blkcnt, mdata_aligned) != blkcnt) { > > > + log_debug("Error reading FWU metadata from the device\n"); > > > + return -EIO; > > > + } > > > + memcpy(mdata, mdata_aligned, sizeof(struct fwu_mdata)); > > > + } else { > > > > else if ? > > > > > + if (blk_dwrite(desc, blk_start, blkcnt, mdata) != blkcnt) { > > > + log_debug("Error writing FWU metadata to the device\n"); > > > + return -EIO; > > > + } > > > + } > > > + > > > + return 0; > > > +} > > > + > > > +static int fwu_gpt_update_mdata(struct udevice *dev, struct fwu_mdata *mdata) > > > +{ > > > + int ret; > > > + struct blk_desc *desc; > > > + uint mdata_parts[2]; > > > + struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); > > > + > > > + desc = dev_get_uclass_plat(priv->blk_dev); > > > > dev_get_uclass_plat might return NULL, gpt_read_write_mdata() doesn't check > > against NULL and then it ends up calling gpt_get_mdata_disk_part() which > > then calls part_get_info(). I don't think anyone checks for the desc ptr > > > > And I think this is a problem overall in all the callbacks belowe that > > invoke dev_get_uclass_plat() > > dev_get_uclass_plat() returns NULL only when the dev parameter passed > to the function is NULL. And that won't happen since that would mean > that the mdata_dev is NULL, and in such a scenario the driver's probe > function would fail. So these functions would not get called with desc > being NULL. > > -sughosh Ok makes sense. Acked-by: Ilias Apalodimas Thanks /Ilias > > > [...]