From patchwork Wed Sep 30 10:07:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis de Bethencourt X-Patchwork-Id: 7295171 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 14D909F1D5 for ; Wed, 30 Sep 2015 10:08:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4197420663 for ; Wed, 30 Sep 2015 10:08:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5489020664 for ; Wed, 30 Sep 2015 10:08:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933115AbbI3KHX (ORCPT ); Wed, 30 Sep 2015 06:07:23 -0400 Received: from lists.s-osg.org ([54.187.51.154]:40093 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932708AbbI3KHU (ORCPT ); Wed, 30 Sep 2015 06:07:20 -0400 Received: from snow.seri.co.uk (cpc9-slam5-2-0-cust824.2-4.cable.virginm.net [81.108.163.57]) by lists.s-osg.org (Postfix) with ESMTPSA id 56A7A462B3; Wed, 30 Sep 2015 03:07:19 -0700 (PDT) From: Luis de Bethencourt To: linux-kernel@vger.kernel.org Cc: hans.verkuil@cisco.com, mchehab@osg.samsung.com, linux-media@vger.kernel.org, Luis de Bethencourt Subject: [PATCH] [media] go7007: fix returned errno codes in do_special() Date: Wed, 30 Sep 2015 11:07:15 +0100 Message-Id: <1443607635-8072-1-git-send-email-luisbg@osg.samsung.com> X-Mailer: git-send-email 2.5.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed. Since the error number is propagated, the caller will get a -EPERM which is the wrong error condition. Also, the smatch tool complains with the following warnings: gen_mjpeghdr_to_package() warn: returning -1 instead of -ENOMEM is sloppy gen_mpeg1hdr_to_package() warn: returning -1 instead of -ENOMEM is sloppy gen_mpeg4hdr_to_package() warn: returning -1 instead of -ENOMEM is sloppy Signed-off-by: Luis de Bethencourt --- drivers/media/usb/go7007/go7007-fw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/go7007/go7007-fw.c b/drivers/media/usb/go7007/go7007-fw.c index 5f4c9b9..60bf5f0 100644 --- a/drivers/media/usb/go7007/go7007-fw.c +++ b/drivers/media/usb/go7007/go7007-fw.c @@ -379,7 +379,7 @@ static int gen_mjpeghdr_to_package(struct go7007 *go, __le16 *code, int space) buf = kzalloc(4096, GFP_KERNEL); if (buf == NULL) - return -1; + return -ENOMEM; for (i = 1; i < 32; ++i) { mjpeg_frame_header(go, buf + size, i); @@ -646,7 +646,7 @@ static int gen_mpeg1hdr_to_package(struct go7007 *go, buf = kzalloc(5120, GFP_KERNEL); if (buf == NULL) - return -1; + return -ENOMEM; framelen[0] = mpeg1_frame_header(go, buf, 0, 1, PFRAME); if (go->interlace_coding) @@ -832,7 +832,7 @@ static int gen_mpeg4hdr_to_package(struct go7007 *go, buf = kzalloc(5120, GFP_KERNEL); if (buf == NULL) - return -1; + return -ENOMEM; framelen[0] = mpeg4_frame_header(go, buf, 0, PFRAME); i = 368;