[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150721191512.GB21710@kroah.com>
Date: Tue, 21 Jul 2015 12:15:12 -0700
From: Greg KH <gregkh@...uxfoundation.org>
To: Stephen Chandler Paul <cpaul@...hat.com>
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Mauro Carvalho Chehab <mchehab@....samsung.com>,
Arnd Bergmann <arnd@...db.de>, Joe Perches <joe@...ches.com>,
Jiri Slaby <jslaby@...e.com>,
Vishnu Patekar <vishnupatekar0510@...il.com>,
Sebastian Ott <sebott@...ux.vnet.ibm.com>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-input@...r.kernel.org, linux-api@...r.kernel.org,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Hans de Goede <hdegoede@...hat.com>
Subject: Re: [RFC] Input: Add ps2emu module
On Tue, Jul 21, 2015 at 03:07:14PM -0400, Stephen Chandler Paul wrote:
> +#define ps2emu_warn(format, args...) \
> + dev_warn(ps2emu_misc.this_device, format, ## args)
Don't make a wrapper function for another wrapper function, just spell
the thing out in the code, makes it much easier to debug and maintain
over time.
It will also cause you to rename "this_device" to "dev" to make it
easier to type :)
> +static int ps2emu_char_open(struct inode *inode, struct file *file)
> +{
> + struct ps2emu_device *ps2emu = NULL;
> +
> + ps2emu = kzalloc(sizeof(struct ps2emu_device), GFP_KERNEL);
> + if (!ps2emu)
> + return -ENOMEM;
> +
> + init_waitqueue_head(&ps2emu->waitq);
> +
> + ps2emu->serio.write = ps2emu_device_write;
> + ps2emu->serio.port_data = ps2emu;
> +
> + file->private_data = ps2emu;
> +
> + nonseekable_open(inode, file);
Why call this at all?
> + ret = copy_to_user(buffer, &ps2emu->buf[ps2emu->tail], copylen);
> + if (ret)
> + return ret;
Wrong error value, please return -EFAULT.
> + rc = copy_from_user(&cmd, buffer, sizeof(cmd));
> + if (rc)
> + return rc;
Same thing here, -EFAULT.
> + case PS2EMU_CMD_SEND_INTERRUPT:
> + if (unlikely(!ps2emu->running)) {
Unless you can verify likely/unlikely actually makes a difference in
your code, don't ever use it. Hint, it's not needed here.
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists