From: Dan Carpenter <dan.carpenter@oracle.com>
To: wens@csie.org
Cc: Olof Johansson <olof@lixom.net>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
linux-arm-kernel@lists.infradead.org
Subject: [bug report] bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus
Date: Tue, 18 Dec 2018 11:36:13 +0300 [thread overview]
Message-ID: <20181218083613.GD440@kadam> (raw)
In-Reply-To: <20181218082800.GC440@kadam>
I totally don't understand the sunxi_rsb_device_create() function. It's
basically a no-op. There is a lot of code to deal with sunxi_rsb_device
devices but there is no function to create them so it seems like dead
code.
What am I missing?
drivers/bus/sunxi-rsb.c
198 static struct sunxi_rsb_device *sunxi_rsb_device_create(struct sunxi_rsb *rsb,
199 struct device_node *node, u16 hwaddr, u8 rtaddr)
200 {
201 int err;
202 struct sunxi_rsb_device *rdev;
203
204 rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
205 if (!rdev)
206 return ERR_PTR(-ENOMEM);
207
208 rdev->rsb = rsb;
209 rdev->hwaddr = hwaddr;
210 rdev->rtaddr = rtaddr;
211 rdev->dev.bus = &sunxi_rsb_bus;
212 rdev->dev.parent = rsb->dev;
213 rdev->dev.of_node = node;
214 rdev->dev.release = sunxi_rsb_dev_release;
215
216 dev_set_name(&rdev->dev, "%s-%x", RSB_CTRL_NAME, hwaddr);
217
218 err = device_register(&rdev->dev);
219 if (err < 0) {
220 dev_err(&rdev->dev, "Can't add %s, status %d\n",
221 dev_name(&rdev->dev), err);
222 goto err_device_add;
223 }
224
225 dev_dbg(&rdev->dev, "device %s registered\n", dev_name(&rdev->dev));
226
227 err_device_add:
228 put_device(&rdev->dev);
229
230 return ERR_PTR(err);
We call put_device() on the success path and return NULL. The caller
checks to see if it is an error pointer, and prints an error message.
NULL isn't an error pointer so it doesn't cause any problems but it also
doesn't do anything.
The caller doesn't save the returned devices either so there seems to
be a bunch of code missing...
231 }
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2018-12-18 8:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 8:28 [PATCH] bus: sunxi-rsb: Fix a small memory leak Dan Carpenter
2018-12-18 8:36 ` Dan Carpenter [this message]
2018-12-18 11:48 ` [bug report] bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus Robin Murphy
2018-12-18 12:27 ` Chen-Yu Tsai
2018-12-18 12:51 ` [PATCH] bus: sunxi-rsb: Fix a small memory leak Chen-Yu Tsai
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=20181218083613.GD440@kadam \
--to=dan.carpenter@oracle.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maxime.ripard@free-electrons.com \
--cc=olof@lixom.net \
--cc=wens@csie.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).