All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hsin-Yi Wang <hsinyi@chromium.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Robert Foss <robert.foss@linaro.org>,
	Rob Herring <robh+dt@kernel.org>, Xin Ji <xji@analogixsemi.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Andrzej Hajda <a.hajda@samsung.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Maxime Ripard <maxime@cerno.tech>
Subject: Re: [PATCH v2 1/3] drm/bridge: anx7625: Convert to use devm_kzalloc
Date: Thu, 13 Jan 2022 16:30:20 +0800	[thread overview]
Message-ID: <CAJMQK-jZgw0Kw0ON8sY=+FFf_Z_Pys48DN+r+g6cCUqcw_7-8A@mail.gmail.com> (raw)
In-Reply-To: <2e676870-11f2-b5fa-faf1-d6633e801a5a@wanadoo.fr>

On Thu, Jan 13, 2022 at 4:04 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 13/01/2022 à 08:31, Hsin-Yi Wang a écrit :
> > Use devm_kzalloc instead of kzalloc and drop kfree(). Let the memory
> > handled by driver detach.
> >
> > Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> > Reviewed-by: Xin Ji <xji@analogixsemi.com>
> > ---
> >   drivers/gpu/drm/bridge/analogix/anx7625.c | 9 +++------
> >   1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 0b858c78abe8b6..dbe708eb3bcf11 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -2515,7 +2515,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >               return -ENODEV;
> >       }
> >
> > -     platform = kzalloc(sizeof(*platform), GFP_KERNEL);
> > +     platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL);
> >       if (!platform) {
> >               DRM_DEV_ERROR(dev, "fail to allocate driver data\n");
> >               return -ENOMEM;
> > @@ -2527,7 +2527,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >       if (ret) {
> >               if (ret != -EPROBE_DEFER)
> >                       DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
> > -             goto free_platform;
> > +             return ret;
> >       }
> >
> >       platform->client = client;
> > @@ -2552,7 +2552,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >       if (!platform->hdcp_workqueue) {
> >               dev_err(dev, "fail to create work queue\n");
> >               ret = -ENOMEM;
> > -             goto free_platform;
> > +             return ret;
> >       }
> >
> >       platform->pdata.intp_irq = client->irq;
> > @@ -2637,9 +2637,6 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >       if (platform->hdcp_workqueue)
> >               destroy_workqueue(platform->hdcp_workqueue);
> >
> > -free_platform:
> > -     kfree(platform);
> > -
> >       return ret;
> >   }
> >
>
> Hi,
>
> you also need to update anx7625_i2c_remove() accordingly, otherwise you
> introduce a double free.
>
Hi,

Updated in v3.
> CJ
>
>

WARNING: multiple messages have this Message-ID (diff)
From: Hsin-Yi Wang <hsinyi@chromium.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: devicetree@vger.kernel.org,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, Jonas Karlman <jonas@kwiboo.se>,
	linux-kernel@vger.kernel.org,
	Robert Foss <robert.foss@linaro.org>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Rob Herring <robh+dt@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sam Ravnborg <sam@ravnborg.org>, Xin Ji <xji@analogixsemi.com>,
	Maxime Ripard <maxime@cerno.tech>
Subject: Re: [PATCH v2 1/3] drm/bridge: anx7625: Convert to use devm_kzalloc
Date: Thu, 13 Jan 2022 16:30:20 +0800	[thread overview]
Message-ID: <CAJMQK-jZgw0Kw0ON8sY=+FFf_Z_Pys48DN+r+g6cCUqcw_7-8A@mail.gmail.com> (raw)
In-Reply-To: <2e676870-11f2-b5fa-faf1-d6633e801a5a@wanadoo.fr>

On Thu, Jan 13, 2022 at 4:04 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 13/01/2022 à 08:31, Hsin-Yi Wang a écrit :
> > Use devm_kzalloc instead of kzalloc and drop kfree(). Let the memory
> > handled by driver detach.
> >
> > Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> > Reviewed-by: Xin Ji <xji@analogixsemi.com>
> > ---
> >   drivers/gpu/drm/bridge/analogix/anx7625.c | 9 +++------
> >   1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 0b858c78abe8b6..dbe708eb3bcf11 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -2515,7 +2515,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >               return -ENODEV;
> >       }
> >
> > -     platform = kzalloc(sizeof(*platform), GFP_KERNEL);
> > +     platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL);
> >       if (!platform) {
> >               DRM_DEV_ERROR(dev, "fail to allocate driver data\n");
> >               return -ENOMEM;
> > @@ -2527,7 +2527,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >       if (ret) {
> >               if (ret != -EPROBE_DEFER)
> >                       DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
> > -             goto free_platform;
> > +             return ret;
> >       }
> >
> >       platform->client = client;
> > @@ -2552,7 +2552,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >       if (!platform->hdcp_workqueue) {
> >               dev_err(dev, "fail to create work queue\n");
> >               ret = -ENOMEM;
> > -             goto free_platform;
> > +             return ret;
> >       }
> >
> >       platform->pdata.intp_irq = client->irq;
> > @@ -2637,9 +2637,6 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> >       if (platform->hdcp_workqueue)
> >               destroy_workqueue(platform->hdcp_workqueue);
> >
> > -free_platform:
> > -     kfree(platform);
> > -
> >       return ret;
> >   }
> >
>
> Hi,
>
> you also need to update anx7625_i2c_remove() accordingly, otherwise you
> introduce a double free.
>
Hi,

Updated in v3.
> CJ
>
>

  reply	other threads:[~2022-01-13  8:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13  7:31 [PATCH v2 1/3] drm/bridge: anx7625: Convert to use devm_kzalloc Hsin-Yi Wang
2022-01-13  7:31 ` Hsin-Yi Wang
2022-01-13  7:31 ` [PATCH v2 2/3] drm/bridge: anx7625: Support reading edid through aux channel Hsin-Yi Wang
2022-01-13  7:31   ` Hsin-Yi Wang
2022-01-13  7:31 ` [PATCH v2 3/3] dt-bindings: drm/bridge: anx7625: Add aux-bus node Hsin-Yi Wang
2022-01-13  7:31   ` Hsin-Yi Wang
2022-01-13  8:04 ` [PATCH v2 1/3] drm/bridge: anx7625: Convert to use devm_kzalloc Christophe JAILLET
2022-01-13  8:04   ` Christophe JAILLET
2022-01-13  8:30   ` Hsin-Yi Wang [this message]
2022-01-13  8:30     ` Hsin-Yi Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJMQK-jZgw0Kw0ON8sY=+FFf_Z_Pys48DN+r+g6cCUqcw_7-8A@mail.gmail.com' \
    --to=hsinyi@chromium.org \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime@cerno.tech \
    --cc=narmstrong@baylibre.com \
    --cc=robert.foss@linaro.org \
    --cc=robh+dt@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=xji@analogixsemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.