[Ocfs2-devel] [patch] Fix: 'return -ENOMEM' instead of 'return ENOMEM'

Dave Airlie airlied at gmail.com
Thu Nov 12 00:43:26 PST 2009


On Thu, Nov 12, 2009 at 6:10 PM, Ingo Molnar <mingo at elte.hu> wrote:
>
> * Andrew Morton <akpm at linux-foundation.org> wrote:
>
>> > @@ -3730,7 +3730,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
>> >
>> >     s = kmalloc(sizeof(*s), GFP_KERNEL);
>> >     if (!s)
>> > -           return ENOMEM;
>> > +           return -ENOMEM;
>> >
>> >     trace_seq_init(s);
>> >
>>
>> lol, there we go again.
>>
>> Andy, can we have a checkpatch rule please?
>
> Note, that will upset creative uses of error codes i guess, such as
> fs/xfs/.
>
> But yeah, +1 from me too.
>
> Ob'post'mortem - looked for similar patterns in the kernel and there's
> quite a few bugs there:
>
>  include/net/inet_hashtables.h:                  return ENOMEM;         # bug
>  drivers/scsi/aic7xxx/aic7xxx_osm.c:             return ENOMEM;         # works but weird
>  drivers/scsi/cxgb3i/cxgb3i_offload.c:           return ENOMEM;         # works but weird
>  fs/ocfs2/dlm/dlmrecovery.c:            return EAGAIN;                  # bug
>  drivers/block/cciss_scsi.c:             return ENXIO;                  # works but weird
>  drivers/gpu/drm/radeon/radeon_irq.c:                    return EINVAL; # bug
>  drivers/gpu/drm/radeon/radeon_irq.c:                    return EINVAL; # bug
>  drivers/isdn/hardware/mISDN/hfcmulti.c:         return EINVAL;         # bug
>
> 5 out of 8 places look buggy - i.e. more than 60% - a checkpatch warning
> would avoid real bugs here. (even ignoring the cleanliness effects of
> using proper error propagation)
>
> Cc:-ed affected maintainers. The rightmost column are my observations.
> Below is the patch fixing these.
>
>        Ingo
>
> Signed-off-by: Ingo Molnar <mingo at elte.hu>

Looks good to me for radeon bits.

Acked-by: Dave Airlie <airlied at redhat.com>

Dave.



More information about the Ocfs2-devel mailing list