Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp54120pxh; Thu, 7 Apr 2022 13:46:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgtXN02bqrgo6pEweOarkrlWxMJv/h71UiYPsA0E6CKWcXSF+z3geeLLVQauzBQJc7Gwn1 X-Received: by 2002:aa7:8385:0:b0:4f6:ef47:e943 with SMTP id u5-20020aa78385000000b004f6ef47e943mr16255072pfm.38.1649364397856; Thu, 07 Apr 2022 13:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649364397; cv=none; d=google.com; s=arc-20160816; b=hkcgYHUeuKo/nglZ9u+Or5Gr0DJJ08mTB1W5U8e2lh6PnDdaETs4+oTfxygZolhDl8 D3lcf/8nZJNqUCp3TLfgh1uDq8fWEqHDo8kAWk+L3NFhOGWBLOUnJLRXDRzcnpPzxxZW YO/ir3FFkW4curRbuDEH7km3zQrykpv1EQz3yrykaLsT5ORzZ8O+X0a+Ox8f5tfSEY2g Al6Q59Fv+clUKsAnMiCtdXk7NBVyoKU/NGan3/0VZH0v8Z6LgcBWtG2u6x/OHbcgS8nu b8rVSDxeuapF07X30HSoNDSaII6YA+8I7yVRDkR6ti8RBjyld2ugrZrgwsN3Qasqeihk nAsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=W+1rOYPnAZkSAoFE9WFZU5G0otnwYX5qic+yQYdsVYw=; b=jMBIudiJ4Gm83mx/ebyeaxT6JyY/D0P9fzBxICO8upwzyuidsV8G3Hi52OH9aOiZGC Fziss+Bg483VwZJSlKCmT6x5NZXTV5bwe5ZQ5ucVA1+o/P/pi8AucnIYAAhaBsDFfJWV GMKxc4f0zGHptpequATYO7QNf6Jub9O6eHcZKQjpJSEhTsUlciH121WhxNUzgesw47q9 ztKYcgw0livGpB2EoashkMIg02kBbHaPWuU8yzhjACHjaVrldJjC5VRGGSDl2hCUNC9O 6O8atIPvrktOzlniMJd21wj4OeOBKl8nuMJ0jneLYTEn6nS0QcPDoOs2J5jGSrIj+bhD JOGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=ikVAtHHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r63-20020a17090a43c500b001ca3696234bsi2707351pjg.89.2022.04.07.13.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:46:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=ikVAtHHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D9DB0262411; Thu, 7 Apr 2022 12:54:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240323AbiDGJFb (ORCPT + 99 others); Thu, 7 Apr 2022 05:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbiDGJFZ (ORCPT ); Thu, 7 Apr 2022 05:05:25 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D87718E00 for ; Thu, 7 Apr 2022 02:03:24 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id g20so5612623edw.6 for ; Thu, 07 Apr 2022 02:03:24 -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=W+1rOYPnAZkSAoFE9WFZU5G0otnwYX5qic+yQYdsVYw=; b=ikVAtHHNfS1qoYViGuL94fCuQ8C+sS0IgCobHN4E5+VSj6BZL+yj96oOWGAUUkJR6j NRB1pT3xl3CiOTSvTd6VKHK50u0XaKBOmFDpQNAb1T85d611C2juxICUAgCCXG7prKLe nXmGV880tstI6aOa/b2NvPHEJAJZP0kATx3Sg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=W+1rOYPnAZkSAoFE9WFZU5G0otnwYX5qic+yQYdsVYw=; b=qteXlEZgYA/pw5rwI6qBNqfsB2C6+76cUn/zssNsw39IIsjyJA8gWw6TBAHouvP8NU ScGKk3mJD5iVSE4cZgjsqDdopLO/LWDogDA8BgdXWYBPuY3KzlrpFKiLX4o2cgeyB0Oz Z1axkl0lViI4ng0ncasfSDs3nGZUWkU4kJzs6vTaogTbwAMa6XEg1yG4MXAES89FWJoD DnvPz/R7lL9ldJ6yt7TZvQYIvoHgl2lixdw3Nq6HMDUxtIaAcmS7LVpjsgR2qADKDUrO R/cPrmFmMb2WEETnnCxfWkbm/orXTrtt5aMxZgQGnU+cyBY424HfpvGqhoplH2rfevOq bCsQ== X-Gm-Message-State: AOAM530NTH0/knoOr5mMh4nLCuA6uBtQSm3Nm6Ue4+4sEowF552a6kAe fm8oavndYPNGEYtsUsEUYO0l8nd809VYa7HGhzY= X-Received: by 2002:a05:6402:438d:b0:419:4550:d52b with SMTP id o13-20020a056402438d00b004194550d52bmr12998429edc.83.1649322203124; Thu, 07 Apr 2022 02:03:23 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id f13-20020a50bf0d000000b0041cdd9c9147sm3857173edk.40.2022.04.07.02.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 02:03:22 -0700 (PDT) Date: Thu, 7 Apr 2022 11:03:20 +0200 From: Daniel Vetter To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann , Daniel Vetter , Borislav Petkov , Greg Kroah-Hartman , Miaoqian Lin Subject: Re: [RESEND RFC PATCH 1/5] firmware: sysfb: Make sysfb_create_simplefb() return a pdev pointer Message-ID: Mail-Followup-To: Javier Martinez Canillas , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann , Borislav Petkov , Greg Kroah-Hartman , Miaoqian Lin References: <20220406213919.600294-1-javierm@redhat.com> <20220406213919.600294-2-javierm@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220406213919.600294-2-javierm@redhat.com> X-Operating-System: Linux phenom 5.10.0-8-amd64 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 06, 2022 at 11:39:15PM +0200, Javier Martinez Canillas wrote: > This function just returned 0 on success or an errno code on error, but it > could be useful to sysfb_init() to get a pointer to the device registered. > > Signed-off-by: Javier Martinez Canillas You need to rebase this onto 202c08914ba5 ("firmware: sysfb: fix platform-device leak in error path") which fixes the same error path leak you are fixing in here too. Or we just have a neat conflict when merging :-) But in that case please mention that you fix the error path leak too so it's less confusing when Linus or someone needs to resolve the conflict. Anyway Reviewed-by: Daniel Vetter > --- > > drivers/firmware/sysfb.c | 4 ++-- > drivers/firmware/sysfb_simplefb.c | 24 +++++++++++++++--------- > include/linux/sysfb.h | 10 +++++----- > 3 files changed, 22 insertions(+), 16 deletions(-) > > diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c > index 2bfbb05f7d89..b032f40a92de 100644 > --- a/drivers/firmware/sysfb.c > +++ b/drivers/firmware/sysfb.c > @@ -46,8 +46,8 @@ static __init int sysfb_init(void) > /* try to create a simple-framebuffer device */ > compatible = sysfb_parse_mode(si, &mode); > if (compatible) { > - ret = sysfb_create_simplefb(si, &mode); > - if (!ret) > + pd = sysfb_create_simplefb(si, &mode); > + if (!IS_ERR(pd)) > return 0; > } > > diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c > index 76c4abc42a30..c42648ed3aad 100644 > --- a/drivers/firmware/sysfb_simplefb.c > +++ b/drivers/firmware/sysfb_simplefb.c > @@ -57,8 +57,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si, > return false; > } > > -__init int sysfb_create_simplefb(const struct screen_info *si, > - const struct simplefb_platform_data *mode) > +__init struct platform_device *sysfb_create_simplefb(const struct screen_info *si, > + const struct simplefb_platform_data *mode) > { > struct platform_device *pd; > struct resource res; > @@ -76,7 +76,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si, > base |= (u64)si->ext_lfb_base << 32; > if (!base || (u64)(resource_size_t)base != base) { > printk(KERN_DEBUG "sysfb: inaccessible VRAM base\n"); > - return -EINVAL; > + return ERR_PTR(-EINVAL); > } > > /* > @@ -93,7 +93,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si, > length = mode->height * mode->stride; > if (length > size) { > printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n"); > - return -EINVAL; > + return ERR_PTR(-EINVAL); > } > length = PAGE_ALIGN(length); > > @@ -104,25 +104,31 @@ __init int sysfb_create_simplefb(const struct screen_info *si, > res.start = base; > res.end = res.start + length - 1; > if (res.end <= res.start) > - return -EINVAL; > + return ERR_PTR(-EINVAL); > > pd = platform_device_alloc("simple-framebuffer", 0); > if (!pd) > - return -ENOMEM; > + return ERR_PTR(-ENOMEM); > > sysfb_apply_efi_quirks(pd); > > ret = platform_device_add_resources(pd, &res, 1); > if (ret) { > platform_device_put(pd); > - return ret; > + return ERR_PTR(ret); > } > > ret = platform_device_add_data(pd, mode, sizeof(*mode)); > if (ret) { > platform_device_put(pd); > - return ret; > + return ERR_PTR(ret); > } > > - return platform_device_add(pd); > + ret = platform_device_add(pd); > + if (ret) { > + platform_device_put(pd); > + return ERR_PTR(ret); > + } > + > + return pd; > } > diff --git a/include/linux/sysfb.h b/include/linux/sysfb.h > index b0dcfa26d07b..708152e9037b 100644 > --- a/include/linux/sysfb.h > +++ b/include/linux/sysfb.h > @@ -72,8 +72,8 @@ static inline void sysfb_apply_efi_quirks(struct platform_device *pd) > > bool sysfb_parse_mode(const struct screen_info *si, > struct simplefb_platform_data *mode); > -int sysfb_create_simplefb(const struct screen_info *si, > - const struct simplefb_platform_data *mode); > +struct platform_device *sysfb_create_simplefb(const struct screen_info *si, > + const struct simplefb_platform_data *mode); > > #else /* CONFIG_SYSFB_SIMPLE */ > > @@ -83,10 +83,10 @@ static inline bool sysfb_parse_mode(const struct screen_info *si, > return false; > } > > -static inline int sysfb_create_simplefb(const struct screen_info *si, > - const struct simplefb_platform_data *mode) > +static inline struct platform_device *sysfb_create_simplefb(const struct screen_info *si, > + const struct simplefb_platform_data *mode) > { > - return -EINVAL; > + return ERR_PTR(-EINVAL); > } > > #endif /* CONFIG_SYSFB_SIMPLE */ > -- > 2.35.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch