lkml.org 
[lkml]   [2018]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC 2/5] ia64/sn/hwperf: use seq_open_data
On 2 March 2018 at 00:37, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> This code should check the return value of seq_open(); if it failed,
> file->private_data is NULL. But we can avoid the issue entirely and
> simplify the code by letting seq_open_data() set the ->private member
> to objbuf.
>
> if ((e = sn_hwperf_enum_objects(&nobj, &objbuf)) == 0) {
> - e = seq_open(file, &sn_topology_seq_ops);
> - seq = file->private_data;
> - seq->private = objbuf;
> + e = seq_open_data(file, &sn_topology_seq_ops, objbuf);
> }

Well, this turns a NULL deref into a resource leak; we still need to
add a check of the return value and vfree(objbuf) on failure.

Rasmus

\
 
 \ /
  Last update: 2018-03-02 09:23    [W:0.107 / U:0.832 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site