From patchwork Sun Sep 13 03:23:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ellingsworth X-Patchwork-Id: 47125 X-Patchwork-Delegate: dougsland@redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8D3ThhD005597 for ; Sun, 13 Sep 2009 03:29:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754875AbZIMD3i (ORCPT ); Sat, 12 Sep 2009 23:29:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754643AbZIMD3i (ORCPT ); Sat, 12 Sep 2009 23:29:38 -0400 Received: from mail-qy0-f185.google.com ([209.85.221.185]:34967 "EHLO mail-qy0-f185.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754131AbZIMD3i (ORCPT ); Sat, 12 Sep 2009 23:29:38 -0400 X-Greylist: delayed 391 seconds by postgrey-1.27 at vger.kernel.org; Sat, 12 Sep 2009 23:29:11 EDT Received: by mail-qy0-f185.google.com with SMTP id 15so1729687qyk.15 for ; Sat, 12 Sep 2009 20:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :reply-to:user-agent:mime-version:to:subject:content-type; bh=puWmX0JFFHwtaTNQGe6C/iDpCl1SiYWh2+rdI2oX0EA=; b=SBi4mIEx1RikeqV//JJJb8FHKYpnTh8x1pB57iQ/2Gj/p/7THgrP5ZVedHt1FEKOHE DRFgOlTpWG62tPJkFQI/0M9nFbvuaHkTrld2mjVPp+zNd73VnDbJYxOFeP6D3hC/OZW/ 9sLAwKmeqcZtMdt4PFPdfcQfIhYRWN+Tq9/cE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:content-type; b=uzKkZRiBYLvKXlKt6AZ8LBs42HztGfaNlx66QN8dc6kVMGyVGZYcsLELy6cJ4vp3F2 A7UfSV2xjCBhib64H7flKI36z5817O/wznGlgaFAl5uWjqSyRvhuQQbvEOUZJHqgdKHe Ynp93TrgRE/gxGKo+OMM6AT1abFTzFd7mxQ8I= Received: by 10.224.33.7 with SMTP id f7mr4167169qad.42.1252812198432; Sat, 12 Sep 2009 20:23:18 -0700 (PDT) Received: from ?192.168.10.110? (cpe-71-72-62-249.neo.res.rr.com [71.72.62.249]) by mx.google.com with ESMTPS id 6sm2725901qwk.31.2009.09.12.20.23.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 12 Sep 2009 20:23:17 -0700 (PDT) Message-ID: <4AAC659C.8040004@gmail.com> Date: Sat, 12 Sep 2009 23:23:08 -0400 From: David Ellingsworth Reply-To: david@identd.dyndns.org User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: linux-media@vger.kernel.org, klimov.linux@gmail.com Subject: [RFC/RFT 13/14] radio-mr800: simplify device warnings Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From 8c441616f67011244cb15bc1a3dda6fd8706ecd2 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 16:04:44 -0400 Subject: [PATCH 08/14] mr800: fix potential use after free Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) /* vidioc_querycap - query device capabilities */ From af0aeff199bfba73db6cfcf540936c4c9279aad1 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 22:03:16 -0400 Subject: [PATCH 13/14] mr800: simplify device warnings Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 78 ++++++++++++------------------------ 1 files changed, 26 insertions(+), 52 deletions(-) diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index ed734bb..4d955aa 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -186,8 +186,10 @@ static int amradio_set_mute(struct amradio_device *radio, char argument) retval = usb_bulk_msg(radio->usbdev, usb_sndintpipe(radio->usbdev, 2), (void *) (radio->buffer), BUFFER_LENGTH, &size, USB_TIMEOUT); - if (retval < 0 || size != BUFFER_LENGTH) + if (retval < 0 || size != BUFFER_LENGTH) { + amradio_dev_warn(&radio->videodev.dev, "set mute failed\n"); return retval; + } radio->muted = argument; @@ -216,7 +218,7 @@ static int amradio_setfreq(struct amradio_device *radio, int freq) (void *) (radio->buffer), BUFFER_LENGTH, &size, USB_TIMEOUT); if (retval < 0 || size != BUFFER_LENGTH) - return retval; + goto out_err; /* frequency is calculated from freq_send and placed in first 2 bytes */ radio->buffer[0] = (freq_send >> 8) & 0xff; @@ -230,6 +232,14 @@ static int amradio_setfreq(struct amradio_device *radio, int freq) retval = usb_bulk_msg(radio->usbdev, usb_sndintpipe(radio->usbdev, 2), (void *) (radio->buffer), BUFFER_LENGTH, &size, USB_TIMEOUT); + if (retval < 0 || size != BUFFER_LENGTH) + goto out_err; + + goto out; + +out_err: + amradio_dev_warn(&radio->videodev.dev, "set frequency failed\n"); +out: return retval; } @@ -252,8 +262,10 @@ static int amradio_set_stereo(struct amradio_device *radio, char argument) retval = usb_bulk_msg(radio->usbdev, usb_sndintpipe(radio->usbdev, 2), (void *) (radio->buffer), BUFFER_LENGTH, &size, USB_TIMEOUT); - if (retval < 0 || size != BUFFER_LENGTH) + if (retval < 0 || size != BUFFER_LENGTH) { + amradio_dev_warn(&radio->videodev.dev, "set stereo failed\n"); return retval; + } if (argument == WANT_STEREO) radio->stereo = 1; @@ -313,9 +325,6 @@ static int vidioc_g_tuner(struct file *file, void *priv, * amradio_set_stereo shouldn't be here */ retval = amradio_set_stereo(radio, WANT_STEREO); - if (retval < 0) - amradio_dev_warn(&radio->videodev.dev, - "set stereo failed\n"); strcpy(v->name, "FM"); v->type = V4L2_TUNER_RADIO; @@ -347,15 +356,9 @@ static int vidioc_s_tuner(struct file *file, void *priv, switch (v->audmode) { case V4L2_TUNER_MODE_MONO: retval = amradio_set_stereo(radio, WANT_MONO); - if (retval < 0) - amradio_dev_warn(&radio->videodev.dev, - "set mono failed\n"); break; case V4L2_TUNER_MODE_STEREO: retval = amradio_set_stereo(radio, WANT_STEREO); - if (retval < 0) - amradio_dev_warn(&radio->videodev.dev, - "set stereo failed\n"); break; } @@ -372,9 +375,6 @@ static int vidioc_s_frequency(struct file *file, void *priv, radio->curfreq = f->frequency; retval = amradio_setfreq(radio, radio->curfreq); - if (retval < 0) - amradio_dev_warn(&radio->videodev.dev, - "set frequency failed\n"); return retval; } @@ -427,19 +427,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv, switch (ctrl->id) { case V4L2_CID_AUDIO_MUTE: - if (ctrl->value) { + if (ctrl->value) retval = amradio_set_mute(radio, AMRADIO_STOP); - if (retval < 0) { - amradio_dev_warn(&radio->videodev.dev, - "amradio_stop failed\n"); - } - } else { + else retval = amradio_set_mute(radio, AMRADIO_START); - if (retval < 0) { - amradio_dev_warn(&radio->videodev.dev, - "amradio_start failed\n"); - } - } + break; } @@ -487,16 +479,12 @@ static int usb_amradio_init(struct amradio_device *radio) int retval; retval = amradio_set_mute(radio, AMRADIO_STOP); - if (retval < 0) { - amradio_dev_warn(&radio->videodev.dev, "amradio_stop failed\n"); + if (retval) goto out_err; - } retval = amradio_set_stereo(radio, WANT_STEREO); - if (retval < 0) { - amradio_dev_warn(&radio->videodev.dev, "set stereo failed\n"); + if (retval) goto out_err; - } radio->initialized = 1; goto out; @@ -569,14 +557,11 @@ unlock: static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message) { struct amradio_device *radio = usb_get_intfdata(intf); - int retval; mutex_lock(&radio->lock); if (!radio->muted && radio->initialized) { - retval = amradio_set_mute(radio, AMRADIO_STOP); - if (retval < 0) - dev_warn(&intf->dev, "amradio_stop failed\n"); + amradio_set_mute(radio, AMRADIO_STOP); radio->muted = 0; } @@ -590,7 +575,6 @@ static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message) static int usb_amradio_resume(struct usb_interface *intf) { struct amradio_device *radio = usb_get_intfdata(intf); - int retval; mutex_lock(&radio->lock); @@ -598,24 +582,14 @@ static int usb_amradio_resume(struct usb_interface *intf) goto unlock; if (radio->stereo) - retval = amradio_set_stereo(radio, WANT_STEREO); + amradio_set_stereo(radio, WANT_STEREO); else - retval = amradio_set_stereo(radio, WANT_MONO); + amradio_set_stereo(radio, WANT_MONO); - if (retval < 0) - amradio_dev_warn(&radio->videodev.dev, "set stereo failed\n"); + amradio_setfreq(radio, radio->curfreq); - retval = amradio_setfreq(radio, radio->curfreq); - if (retval < 0) - amradio_dev_warn(&radio->videodev.dev, - "set frequency failed\n"); - - if (!radio->muted) { - retval = amradio_set_mute(radio, AMRADIO_START); - if (retval < 0) - dev_warn(&radio->videodev.dev, - "amradio_start failed\n"); - } + if (!radio->muted) + amradio_set_mute(radio, AMRADIO_START); unlock: dev_info(&intf->dev, "coming out of suspend..\n"); -- 1.6.3.3