parisc: perf: Fix potential NULL pointer dereference

[ Upstream commit 74e3f6e63da6c8e8246fba1689e040bc926b4a1a ]

Fix potential NULL pointer dereference and clean up
coding style errors (code indent, trailing whitespaces).

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Arvind Yadav 2017-03-14 15:24:51 +05:30 committed by Greg Kroah-Hartman
parent 4203f2a738
commit cadfa3a688

View file

@ -195,8 +195,8 @@ static int perf_config(uint32_t *image_ptr);
static int perf_release(struct inode *inode, struct file *file); static int perf_release(struct inode *inode, struct file *file);
static int perf_open(struct inode *inode, struct file *file); static int perf_open(struct inode *inode, struct file *file);
static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos); static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos);
static ssize_t perf_write(struct file *file, const char __user *buf, size_t count, static ssize_t perf_write(struct file *file, const char __user *buf,
loff_t *ppos); size_t count, loff_t *ppos);
static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
static void perf_start_counters(void); static void perf_start_counters(void);
static int perf_stop_counters(uint32_t *raddr); static int perf_stop_counters(uint32_t *raddr);
@ -298,8 +298,8 @@ static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t
* called on the processor that the download should happen * called on the processor that the download should happen
* on. * on.
*/ */
static ssize_t perf_write(struct file *file, const char __user *buf, size_t count, static ssize_t perf_write(struct file *file, const char __user *buf,
loff_t *ppos) size_t count, loff_t *ppos)
{ {
int err; int err;
size_t image_size; size_t image_size;
@ -331,10 +331,10 @@ static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun
/* First check the machine type is correct for /* First check the machine type is correct for
the requested image */ the requested image */
if (((perf_processor_interface == CUDA_INTF) && if (((perf_processor_interface == CUDA_INTF) &&
(interface_type != CUDA_INTF)) || (interface_type != CUDA_INTF)) ||
((perf_processor_interface == ONYX_INTF) && ((perf_processor_interface == ONYX_INTF) &&
(interface_type != ONYX_INTF))) (interface_type != ONYX_INTF)))
return -EINVAL; return -EINVAL;
/* Next check to make sure the requested image /* Next check to make sure the requested image
@ -809,6 +809,10 @@ static int perf_write_image(uint64_t *memaddr)
} }
runway = ioremap_nocache(cpu_device->hpa.start, 4096); runway = ioremap_nocache(cpu_device->hpa.start, 4096);
if (!runway) {
pr_err("perf_write_image: ioremap failed!\n");
return -ENOMEM;
}
/* Merge intrigue bits into Runway STATUS 0 */ /* Merge intrigue bits into Runway STATUS 0 */
tmp64 = __raw_readq(runway + RUNWAY_STATUS) & 0xffecfffffffffffful; tmp64 = __raw_readq(runway + RUNWAY_STATUS) & 0xffecfffffffffffful;